-
Notifications
You must be signed in to change notification settings - Fork 180
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 all flake8 violations in the test/ directory #1021
Fix all flake8 violations in the test/ directory #1021
Conversation
.github/workflows/ci.yml
Outdated
run: flake8 test/conftest.py test/test_dev.py test/test_feed.py test/test_repo_template/asv_test_repo/__init__.py |
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.
What is the goal of this change?
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 wanted flake8 to check the files I changed but I will remove this as it's not necessary
@@ -3,4 +3,4 @@ | |||
|
|||
from __future__ import absolute_import, division, unicode_literals, print_function | |||
|
|||
dummy_value = {dummy_value} | |||
dummy_value = {dummy_value} # noqa |
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.
For a noqa
we should have the error code you want to ignore, not all them. And also a comment explaining why we want flake8 to ignore the problem here, instead of fixing the error.
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.
Thanks, Marc, Let me add this asap to be more descriptive
Thanks for the PR. Added couple of comments, and you also have conflicts to fix. |
…to fix_flake8_03
@datapythonista this PR is ready for your review will await your guidance |
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.
Besides the comments, you will have to fix the conflicts
test/test_dev.py
Outdated
import re | ||
from os.path import abspath, dirname, join, relpath | ||
import shutil | ||
import pytest | ||
|
||
import six | ||
import six # noqa |
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.
Why is this? In case it's really needed you need the error code to skip and the reason.
@@ -3,4 +3,4 @@ | |||
|
|||
from __future__ import absolute_import, division, unicode_literals, print_function | |||
|
|||
dummy_value = {dummy_value} | |||
dummy_value = {dummy_value} # noqa:F821 dummy_value not defined but used |
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 you create an issue for this, and link it here? It may be worth running this test file to see why this test file is not failing in the CI.
@datapythonista this PR is ready for your review again |
test/test_dev.py
Outdated
import re | ||
from os.path import abspath, dirname, join, relpath | ||
import shutil | ||
import pytest | ||
|
||
import six | ||
import six # noqa F401 'six' imported but unused |
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 see why six needs to be imported if it's not used. What's the error?
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 is only the flake8 check throws an error (F401 'six' imported but unused)
but the tests pass. its the reason I had removed it completely earlier
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.
We already discussed this case few times. What we did was:
- Remove the import
- If something fails in the test, we check the test failure, we try to understand why this import needs to be here, and we add a the noqa with the error code to skip, and a comment for other devs to know
- If it's difficult for you to understand the error, as often requires a lot of experience, just find the error, post it here, so we can discuss and you can learn about it
- Just adding the error from flake8 doesn't add much value. The first question I'll ask myself if I see this code is "why the import hasn't been removed it it's unused". This is what the code/comment should tell us. Regardless of flake8, why we are importing the module if it's not used
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.
sure let me try this
@@ -3,4 +3,4 @@ | |||
|
|||
from __future__ import absolute_import, division, unicode_literals, print_function | |||
|
|||
dummy_value = {dummy_value} | |||
dummy_value = {dummy_value} # noqa:F821 see #1023 Bug: dummy_value is not defined |
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.
Thanks for creating the issue. Did you check why this doesn't raise an error in the 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.
@datapythonista Am thinking it should be raised in the Ci but it is not, its only flakes 8 that is catching 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.
Also what I'm thinking. But the CI is green (both in this PR and in master). So, we are missing something. Can you have a look at what's going on please. If you don't find out easily, please let me know what's your approach to find out and we can discuss about 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.
Let me try to find out, had run pytest on all the files but it's still quite abstract.
FAILED test/test_update.py::test_update_simple[hg] - FileNotFoundError: [Errno 2] No such file or directory: 'hg'
ERROR test/test_repo.py::test_get_branch_commits[hg] - FileNotFoundError: [Errno 2] No such file or directory: 'hg'
ERROR test/test_repo.py::test_get_new_branch_commits[hg-all] - FileNotFoundError: [Errno 2] No such file or directory: 'hg'
ERROR test/test_repo.py::test_get_new_branch_commits[hg-new] - FileNotFoundError: [Errno 2] No such file or directory: 'hg'
ERROR test/test_repo.py::test_get_new_branch_commits[hg-no-new] - FileNotFoundError: [Errno 2] No such file or directory: 'hg'
ERROR test/test_repo.py::test_get_new_branch_commits[hg-new-branch-added-in-config] - FileNotFoundError: [Errno 2] No such file or dire..
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.
@datapythonista kindly share your thoughts on this
when I run rgrep -I "dummy_value" *I can see the variable dummy_value is being used and its imported from the file in question.
def track_find_test(n):
import asv_test_repo
return asv_test_repo.dummy_value[n - 1]
track_find_test.params = [1, 2]
def time_find_test_timeout():
import asv_test_repo, time
if asv_test_repo.dummy_value[1] < 0:
time.sleep(100)
.github/workflows/ci.yml
Outdated
@@ -16,4 +16,4 @@ jobs: | |||
run: flake8 . || true # preventing CI failing while flake8 issues exist | |||
|
|||
- name: flake8 validating correct file(s) | |||
run: flake8 asv/main.py asv/repo.py asv/results.py asv/runner.py asv/statistics.py asv/step_detect.py asv/util.py test/benchmark/ asv/__init__.py asv/benchmarks.py asv/config.py asv/benchmark.py | |||
run: flake8 asv/main.py asv/repo.py asv/results.py asv/runner.py asv/statistics.py asv/step_detect.py asv/util.py test/benchmark/ asv/__init__.py asv/benchmarks.py asv/config.py asv/benchmark.py test/conftest.py test/test_dev.py test/test_feed.py test/test_repo_template/asv_test_repo/__init__.py |
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.
Maybe time to split this in two lines, this is becoming unreadable.
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.
sure,will do this
Hello @datapythonista this PR is ready for your review again |
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.
Thanks @dorothykiz1, this looks great, and will be very useful.
I added couple of minor comments on things that can help, but other than that looks perfect.
.github/workflows/ci.yml
Outdated
|
||
- name: flake8 validating correct file(s) | ||
run: flake8 asv/main.py asv/repo.py asv/results.py asv/runner.py asv/statistics.py asv/step_detect.py asv/util.py test/benchmark/ asv/__init__.py asv/benchmarks.py asv/config.py asv/benchmark.py | ||
run: flake8 . || true # preventing CI failing while flake8 issues exist |
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.
We don't need the || true anymore
, since all the files that would make the CI fail are now excluded.
When you do that, maybe you can also simplify the name of the job now, to just flake8
or similar, since there is only one now, and it's not so complex to understand what each does.
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.
Thanks, let me do this
setup.cfg
Outdated
@@ -1,6 +1,14 @@ | |||
[flake8] | |||
max-line-length = 99 | |||
|
|||
max-line-length = 99, |
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 think we need the comma at the end (and not sure if it can cause problems)
setup.cfg
Outdated
max-line-length = 99 | ||
|
||
max-line-length = 99, | ||
exclude = setup.py,asv/commands,asv/extern,asv/plugins,asv/template/benchmarks, |
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 looks great, thanks.
Only thing I'd do, is to have one file per line. It looks better the way you did it, as it's not super long, but with one line per file PRs will be easier to review when we keep fixing the pending files. And also, conflicts will be easier to solve, if files are fixed in parallel.
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.
Yes, I agree. Let me incorporate all the changes
@datapythonista this PR is ready for your review |
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.
Thanks @dorothykiz1, couple of details, but almost there.
.github/workflows/ci.yml
Outdated
@@ -13,7 +13,4 @@ jobs: | |||
run: pip install flake8 | |||
|
|||
- name: flake8 all repo only show erros |
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 the name I was referring to, it can be just left as just flake8
(it's not true anymore after you remove the || true
that we only show errors, we also fail the CI if they exist).
.github/workflows/ci.yml
Outdated
|
||
- name: flake8 validating correct file(s) | ||
run: flake8 asv/main.py asv/repo.py asv/results.py asv/runner.py asv/statistics.py asv/step_detect.py asv/util.py test/benchmark/ asv/__init__.py asv/benchmarks.py asv/config.py asv/benchmark.py | ||
run: flake8 . # preventing CI failing while flake8 issues exist |
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 remove the comment too, as we're not preventing the CI from failing anymore now.
setup.cfg
Outdated
asv/machine.py, | ||
asv/graph.py, | ||
asv/.pytest_cache/d/asv-wheels/cache/tmp |
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 seems like a temporary file, and I don't think it'll exist in the CI. Can you remove it, and see if the build is still green? I think it should.
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.
Thanks, @datapythonista however these temp files had some flake 8 errors ,that's why I had included their folder,kindly advise
./.pytest_cache/d/asv-wheels/cache/tmp/asv_dummy_test_package_2-0.3.9/asv_dummy_test_package_2/init.py:1:22: W292 no newline at end of file
./.pytest_cache/d/asv-wheels/cache/tmp/asv_dummy_test_package_1-0.14/asv_dummy_test_package_1/init.py:1:21: W292 no newline at end of file
./.pytest_cache/d/asv-wheels/cache/tmp/asv_dummy_test_package_2-0.3.7/asv_dummy_test_package_2/init.py:1:22: W292 no newline at end of file
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 this happening in the CI or locally? I think the CI shouldn't fail, but maybe a good idea anyway to ignore anything in .pytest_cache
directories, since those are temporary. Not sure exactly how to ignore all directories with that name, but I'm sure you'll find out.
setup.cfg
Outdated
benchmarks/step_detect.py, | ||
benchmarks/__init__.py, | ||
.pytest_cache/d/asv-wheels/cache/tmp, |
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.
Another temporary file, same as the previous.
setup.cfg
Outdated
benchmarks/__init__.py, | ||
.pytest_cache/d/asv-wheels/cache/tmp, | ||
docs/source |
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 there is just one Python file in this directory, no big deal, but probably worth having the file here, and not the whole dir (so people who wants to work in any of these know that it's just one file, and doesn't feel intimidated thinking it's lots of things in that dir).
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.
Great, i can add this .this makes sense let me pick the exact files.
@datapythonista this PR is ready for your review |
Did you push your changes? I don't think there is any update since the last review. |
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.
Thanks @dorothykiz1 looks perfect, I'll merge on green
Sure,Thank you @datapythonista |
Thanks @dorothykiz1, really nice |
closes 11
Fix flake8 violations for files below;