-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Enable flake8 and re-enable it everywhere #11477
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
Conversation
pytest.ini
Outdated
@@ -7,8 +7,9 @@ markers = | |||
network: Mark a test that uses the network. | |||
style: Set alternate Matplotlib style temporarily. | |||
|
|||
pep8ignore = | |||
* E111 E114 E115 E116 E121 E122 E123 E124 E125 E126 E127 E128 E129 E131 E226 E240 E241 E242 E243 E244 E245 E246 E247 E248 E249 E265 E266 E704 W503 | |||
flake8-max-line-length = 80 |
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.
Shouldn't this be left at 79 (the default, i.e. remove this line)?
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 got this from @cclauss's PR, but I think you're right, so I'm going to remove 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.
sorry, off-by-one bug on my part.
LOL... #10940 (comment) |
Well, okay, now pyside(2) seems to be broken. Also, I have no idea why, but flake8 make the tests ridiculously slow. I ran a non-parallel test locally and it took ~7 minutes, but with the |
Maybe related tholo/pytest-flake8#19? |
If #11477 (comment) is still an issue, perhaps replace pytest-flake8 by a direct invocation of flake8? (with e.g. https://github.com/snoack/flake8-per-file-ignores for per-file ignores) |
I ran
Sure I didn't have the exceptions turned on or anything (the pep8 test failed). |
Try running PEP8 and flake8 WITHOUT passing thru pytest. |
Well, I tried conda, virtualenv, and even downloading the docker image that Travis used, but I cannot reproduce the slow checks anymore. I guess standalone |
From http://flake8.pycqa.org/en/latest/user/invocation.html $ flake8 . --config=CONFIG # Path to the config file that will be the authoritative config source. This will cause Flake8 to ignore all other configuration files. |
Is the issue that pytest spins up a new flake8 process for each file which just takes forever on the travis vms? |
watching a running test it is not hung, just from 91% on it seems to be taking it's time (and then we hit the 50 minute timeout). |
One minute, 10 seconds to flake8 test the entire repo seems reasonable to me. $ time flake8 . --config=pytest.ini # Python 3.7 on Travis CI
|
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.
Running flake8 from inside pytest has proved to be a bad idea when each file in the repo has its own style rules. Running flake8 standalone with the --config=pytest.ini seems the best approach.
9d55403
to
6fa1391
Compare
At some point in the near future, I would like to get rid of the |
Where does the flake8 output show up in the test? I can't see any evidence that it ran, but maybe I'm looking in the wrong spot... |
That's because it passed 😉 I'll add a message to say it's okay on there. |
Fixes #11550 |
.travis.yml
Outdated
@@ -160,6 +160,9 @@ before_script: | | |||
script: | | |||
echo "Calling pytest with the following arguments: $PYTEST_ADDOPTS" | |||
python -mpytest | |||
if [[ $RUN_FLAKE8 == 1 ]]; then |
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 suspect this is going to have the same issue we discovered in the pytzectomy PR where if the tests fail but flake8 passes, travis will report success.
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.
Probably set -e is the way to go?
Or add || return 1
at the end of each (relevant) line.
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 don't like set -e
; it bleeds into Travis' code and causes spurious errors, so you need to remember to turn it off. The last time that happened, we ended up just removing it instead. I split these into separate entries instead, which does fail correctly.
@@ -25,13 +25,13 @@ def __get__(self, obj, objtype=None): | |||
|
|||
|
|||
class TaggedValueMeta(type): | |||
def __init__(cls, name, bases, dict): |
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.
This is used as a meta-class so I ma not sure that this change is correct (I am also not sure off the top of my head what self
is in this case and when this __init__
gets called).
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 may be that the object is a class/type here, but it's still an instance at this point, so I'm not sure calling it something other than self
is warranted.
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 think that the way this is called in travis will mask failures in the test suite from failing the test.
Anyone can clear this if this is fixed or they are sure I am wrong.
Do the flake8 tests first and the pytests after? |
@cclauss then it won't fail if flake8 fails? #11597 shows that @tacaswell is indeed correct - that failing a test still returns a positive Travis check the way this is setup now.... |
#11597 shows that adding |
Splitting the two commands into separate entries should work fine. |
Thanks everyone! |
PR Summary
Due to the removal of the examples symlink in #11141, pytest was no longer seeing the examples and running pep8 on them. This adds that directory back to pytest's search.
It also adds a rebase of #10940 to enable flake8.
PR Checklist