Skip to content

Fix flake8 violations#1029

Merged
datapythonista merged 9 commits intoairspeed-velocity:masterfrom
dorothykiz1:fix_flake8_05
Feb 16, 2022
Merged

Fix flake8 violations#1029
datapythonista merged 9 commits intoairspeed-velocity:masterfrom
dorothykiz1:fix_flake8_05

Conversation

@dorothykiz1
Copy link
Contributor

Closes 15

Fix flake8 violations in files below;

  • test/test_statistics.py
  • test/test_quickstart.py
  • test/tools.py

Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

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

Looks good, just couple of things that we should revert. Thanks!

@dorothykiz1
Copy link
Contributor Author

@datapythonista this PR is ready for your review

import pytest

from .tools import example_results
from .tools import example_results # noqa :F401 imported but unused
Copy link
Member

Choose a reason for hiding this comment

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

For the comment, we don't want the flake8 error, which doesn't add much value. What we want is to explain why we are ignoring the flake8 error. Reading the comment, the obvious thing to think is that this import should be deleted, since it's imported but unused. A helpful comment would be to say that this is required even if unused, so the example_results fixture is loaded.

For this particular case, what it may make more sense is to move the fixtures from tools.py to the standard conftest.py. This way this import won't be needed, as pytest will take care of everything. We don't want to have such a change in a PR with minor style changes. So, one option would be to:

  • Change this line to something like from . import tools # noqa F401 needed to load fixtures (see #1234)
  • Remove the other noqa because of redefinition of example_results, which shouldn't be needed anymore
  • Open an issue to explain what's going on here, to move the fixtures to the right location

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you @datapythonista
for your review let me incorporate these changes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello @datapythonista this still happens when i remove the # noqa

test/test_results.py:165:31: F811 redefinition of unused 'example_results' from line 17
test/test_results.py:208:39: F811 redefinition of unused 'example_results' from line 17

Copy link
Member

Choose a reason for hiding this comment

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

I left a new review explaining how I would fix this. You need the noqa here with the proposed import, but not the errors you have in your comment I think.

test/tools.py Outdated

try:
import virtualenv
import virtualenv # noqa :F401 imported but unused
Copy link
Member

Choose a reason for hiding this comment

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

Same, this comment doesn't add any value, what we want is to explain why we keep this import even if it's unused, not just the flake8 error message, which doesn't provide any value to the readers of this



def test_backward_compat_load(example_results):
def test_backward_compat_load(example_results): # noqa uses fixture
Copy link
Member

Choose a reason for hiding this comment

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

Can you ignore only the error code we have now.



def test_iter_results(capsys, tmpdir, example_results):
def test_iter_results(capsys, tmpdir, example_results): # noqa uses fixture
Copy link
Member

Choose a reason for hiding this comment

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

same



def test_backward_compat_load(example_results): # noqa uses fixture
def test_backward_compat_load(example_results): # noqa F811
Copy link
Member

Choose a reason for hiding this comment

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

Can you add the comment on why we are ignoring this error please



def test_iter_results(capsys, tmpdir, example_results): # noqa uses fixture
def test_iter_results(capsys, tmpdir, example_results): # noqa F811
Copy link
Member

Choose a reason for hiding this comment

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

same

@datapythonista datapythonista merged commit b2f2345 into airspeed-velocity:master Feb 16, 2022
@datapythonista
Copy link
Member

Thanks @dorothykiz1, very nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants