Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Unit tests

on: [push, pull_request]

jobs:
test_py2:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python 2.7
uses: actions/setup-python@v2
with:
python-version: '2.7'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint diff_cover

- name: Pylint
run: |
pylint --version
pylint --exit-zero xcp/ tests/ setup.py
pylint --exit-zero --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" xcp/ tests/ setup.py > pylint.txt
diff-quality --violations=pylint --html-report pylint-diff.html pylint.txt

- uses: actions/upload-artifact@v3
with:
name: Pylint diff
path: pylint-diff.html
6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,3 @@

# Emacs backup files
*~

# 'xcp' symlink for test harness
/tests/xcp

# 'xcp' symlink for pylint
/xcp
File renamed without changes.
8 changes: 3 additions & 5 deletions run-pylint.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/bin/bash

test -r xcp || ln -sf . xcp

if [[ -z $1 ]]; then
pylint --rcfile=pylint.rc *.py net
if [ $# = 0 ]; then
pylint *.py xcp
else
pylint --rcfile=pylint.rc $1
pylint "$@"
fi
2 changes: 1 addition & 1 deletion xcp/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def openAddress(self, addr):
return False
except Exception as e:
self.lastError = 500
return false
return False
return file

class MountingAccessor(FilesystemAccessor):
Expand Down
6 changes: 5 additions & 1 deletion xcp/cpiofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,10 @@ def seek(self, pos):
self.init()
self.read(pos - self.pos)

def init(self):
Copy link
Contributor

@edwintorok edwintorok Jul 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be done via some of the @abc annotations in python, would https://docs.python.org/3/library/abc.html#abc.abstractmethod (and inheriting from the proper ABC class) fix the pylint warning too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, using abc works just as well. That one is annoying in projects making heavy use of metaclasses (which is why I default to the exception idiom), but it will do the job here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, inheriting from abc.ABC comes with 3.4 only, so we'd have to use something like @six.add_metaclass(abc.ABCMeta) for a 2/3-portable idiom, which I feel brings too much complexity, for no clear advantage over NotImplementedError(). What do you think ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, inheriting from abc.ABC comes with 3.4 only, so we'd have to use something like @six.add_metaclass(abc.ABCMeta) for a 2/3-portable idiom, which I feel brings too much complexity, for no clear advantage over NotImplementedError(). What do you think ?

I think I'd concur with that. My feeling is we want the Py2/Py3 compatibility phase to be relatively short until the migration is complete and then drop the py2 support completely at which point there can be a follow on set of changes to perform code cleanups.

# implemented by subclasses
raise NotImplementedError()

def tell(self):
return self.pos

Expand Down Expand Up @@ -1154,7 +1158,7 @@ def xzopen(cls, name, mode="r", fileobj=None, compresslevel=6):
if fileobj is not None:
fileobj = _XZProxy(fileobj, mode)
else:
fileobj = lzma.LZMAFile(name, mode, options={'level': compresslevel, dict_size: 20 })
fileobj = lzma.LZMAFile(name, mode, options={'level': compresslevel, 'dict_size': 20 })

try:
t = cls.cpioopen(name, mode, fileobj)
Expand Down