-
Notifications
You must be signed in to change notification settings - Fork 200
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
Fix httpcore dependency; fix style linting #257
Fix httpcore dependency; fix style linting #257
Conversation
Hmm… I never considered the typing and style checks to be particularily hard to run. Using docker to run them seems kinda overkill to me, but if people feel this is helpful I'll add this. However, before we do that, could you tell me what output you are seeing when running the |
I didn't have tox installed at all. In the python:3.8.5 docker image its 3.7.0, and when I install tox into my venv its 3.23.0. The tox output, both from the docker runs and with tox now installed into the venv, is two categories of errors. Linting, such as:
And typing, such as:
|
The primary benefit of the docker images is validating against the array of supported python versions easily with a clean build. You could check them individually with separate virtual environments, but then you have to maintain the virtual environments and dependencies could drift. Docker is a clean slate each time. |
I think there's a combination of a small number of legitimate issues the type and style checks are catching, and a larger number of false positives caused by a lack of ignores for checking dependencies (e.g. warnings for I'm going to make some adjustments and push a revision. |
Thank you, now I understand much better what this issue is about! I thought this was merely to workaround some issue you had with |
314d37d
to
06278d1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You just dropped all the Docker-related code I tried to review. What is the plan there?
verify.sh
Outdated
validate 3.5.10 | ||
validate 3.6.13 | ||
validate 3.7.10 | ||
validate 3.8.8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is is possible to use aliases like 3.5
, 3.6
, … here to avoid listing all these detailed versions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can; it's a trade off between build consistency and being automatically on a later point release of Python.
Which would you prefer?
I think ideally it would use the same source of truth as the rest of the build and scrape the config files, but I didn't get that far.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistency is probably better, you're right! It's probably best to test the supported earliest version of each Python minor release.
I think ideally it would use the same source of truth as the rest of the build and scrape the config files, but I didn't get that far.
The current “single source of truth” would be the tool.flit.metadata.requires-python
key in pyproject.toml
, whose value would effectively evaluate to the following Python minimum minor version configuration:
validate 3.5.4
validate 3.6.2
validate 3.7.2
validate 3.8.0
It's not straightforward at all to derive these values programmatically through. :-/
verify.sh
Outdated
validate 3.7.10 | ||
validate 3.8.8 | ||
else | ||
echo "Validating only $1..." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Please use ellipsis (…), instead of three dots (...) here.
verify.sh
Outdated
tag=py-ipfs-http-client-verify:$python_version | ||
|
||
docker build --build-arg PYTHON_VERSION=$python_version -t $tag . | ||
docker run -it -v $(pwd):/source:ro -w /usr/src/app $tag tox -e styleck -e typeck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use docker run --rm
to ensure the used image doesn't stick around needlessly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You just dropped all the Docker-related code I tried to review. What is the plan there?
I thought I was getting some push back on it so I decided to pare down the PR to changes to the library. I can add it back if you like, with changes per the comments you added.
FYI - the linting step of the Travis build now passes. I don't have fixes for the remaining type checks since I'm not familiar enough with protocols to address it.
Do you want me to add the Docker scripts back into this PR, or open a new PR for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please open a new PR for the Docker stuff. The current PR is indeed useful as is, so no need to clutter it further.
Dockerfile
Outdated
FROM python:${PYTHON_VERSION} | ||
|
||
RUN apt-get update -y && apt-get install -y apt-utils tox |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be OK to use the Python -alpine
images here for smaller image download size?
Install command would be apk update && apk add --no-cache py3-tox
in this case.
verify.sh
Outdated
} | ||
|
||
if [ -z "$1" ]; then | ||
echo "Validating supported versions..." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Please use ellipsis (…), instead of three dots (...) here.
entrypoint.sh
Outdated
#!/usr/bin/env bash | ||
|
||
cp -r /source/* /usr/src/app/ | ||
|
||
exec $@ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this script be inlined into the Dockerfile
(less clutter)? Also #!/bin/sh
is sufficient here.
verify.sh
Outdated
python_version=$1 | ||
|
||
echo "Validating version $python_version..." | ||
|
||
tag=py-ipfs-http-client-verify:$python_version | ||
|
||
docker build --build-arg PYTHON_VERSION=$python_version -t $tag . | ||
docker run -it -v $(pwd):/source:ro -w /usr/src/app $tag tox -e styleck -e typeck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please always add double-quotes (") around variable/process substitutions (ie: $tag
→ "${tag}"
) unless you explicitly intend to invoke shell word splitting. Figuring out whitespace issues with shell is a huge PITA otherwise.
test/run-tests.py
Outdated
"# Exclude lines specific to some other Python version from coverage", | ||
"exclude_lines =", | ||
), map(lambda s: "\t" + s, exclusions)))) | ||
( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will behave better here if you move the opening parenthese to the line above. The way it's currently written was actually a workaround to a bug in an older version of the checker. 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will behave better here if you move the opening parenthese to the line above. The way it's currently written was actually a workaround to a bug in an older version of the checker. wink
^ Do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had tried simply moving the parenthesis on line 180 up earlier but it didn't like that. The latest change flattens that entire section and passes the linter.
As a more general note on the Docker thing: It is not really necessary to run the type and style checks in different Python versions. CI only checks the latest version and this is on purpose. For typing, lot's of workarounds were required for pre-3.8 versions type hints, so the hints are provided on a best-effort basis there. The reason for running the type check at all is to ensure our typings are non-contradictionary and this property should not change depending on the 3.8+ Python version run (many mypy bugs permitting), so checking more than one Python version isn't all that helpful. For flake8 the Python version is pretty much totally irrelevant, except that the version needs to be new enough to understand all the syntax used in the project's source code ( |
Linting step for 3.8 build is passing now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor stuff now.
test/run-tests.py
Outdated
"# Exclude lines specific to some other Python version from coverage", | ||
"exclude_lines =", | ||
), map(lambda s: "\t" + s, exclusions)))) | ||
( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will behave better here if you move the opening parenthese to the line above. The way it's currently written was actually a workaround to a bug in an older version of the checker. wink
^ Do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Previous to this change, attempts to run
..resulted in this error:
The error is caused by this part of that line being present in
tox.ini
:This commit does not fix the typing errors referenced in #255 but does demonstrate the typing errors now that the
httpcore
dependency is fixed.