Skip to content

implement type-hints for all our functions #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 15 commits into from
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ venv-*/
.python-version
python3.6.core
man/*.gz
.mypy_cache/
4 changes: 2 additions & 2 deletions .travis/flake8.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Run pep8 on all .py files in all subfolders

tmpafter=$(mktemp)
find ./libiocage/ -name \*.py -exec flake8 --ignore=E203,W391 {} + | grep -v "./libiocage/__init__.py" > ${tmpafter}
find ./libiocage/ -name \*.py -exec flake8 --ignore=E203,E241,W391 {} + | grep -v "./libiocage/__init__.py" > ${tmpafter}
Copy link
Member

Choose a reason for hiding this comment

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

What is E241 good for? The documentation says E241 (*) | multiple spaces after ‘,’, but I can't spot why we need to ignore this rule.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. I added the ignore for spaces after : so we shouldn't need to add another.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

without this,

./libiocage/lib/Jail.py:72:23: E241 multiple spaces after ':'
./libiocage/lib/Jail.py:73:22: E241 multiple spaces after ':'
./libiocage/lib/Jail.py:74:23: E241 multiple spaces after ':'
./libiocage/lib/Jail.py:76:22: E241 multiple spaces after ':'

i've basically just followed @skarekrow's lead of how to indent… structures.

num_errors_after=`cat ${tmpafter} | wc -l`
echo "Current Error Count: ${num_errors_after}"
echo "Current Errors:"
Expand All @@ -17,7 +17,7 @@ echo "Comparing with last stable release: ${last_release}"
git checkout ${last_release}

tmpbefore=$(mktemp)
find ./libiocage/ -name \*.py -exec flake8 --ignore=E203,W391 {} + | grep -v "./libiocage/__init__.py" > ${tmpbefore}
find ./libiocage/ -name \*.py -exec flake8 --ignore=E203,E241,W391 {} + | grep -v "./libiocage/__init__.py" > ${tmpbefore}
num_errors_before=`cat ${tmpbefore} | wc -l`
echo "${last_release}'s Error Count: ${num_errors_before}"

Expand Down
13 changes: 7 additions & 6 deletions libiocage/lib/Distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def __init__(self, host, zfs=None, logger=None):
libiocage.lib.helpers.init_zfs(self, zfs)
libiocage.lib.helpers.init_host(self, host)
self.available_releases = None
self.host = host
self.zfs = zfs
self.logger = logger

Expand Down Expand Up @@ -110,18 +111,18 @@ def _get_eol_list(self) -> List[str]:
_eol = "https://www.freebsd.org/security/unsupported.html"
req = requests.get(_eol)
status = req.status_code == requests.codes.ok
eol_releases = []
eol_releases: List[str] = []
if not status:
req.raise_for_status()

for eol in req.content.decode("iso-8859-1").split():
eol = eol.strip("href=").strip("/").split(">")
eol_line = eol.strip("href=").strip("/").split(">")
# We want a dynamic EOL
try:
if "-RELEASE" in eol[1]:
eol = eol[1].strip('</td')
if eol not in eol_releases:
eol_releases.append(eol)
if "-RELEASE" in eol_line[1]:
eol_candidate = eol_line[1].strip('</td')
if eol_candidate not in eol_releases:
eol_releases.append(eol_candidate)
except IndexError:
pass

Expand Down
Loading