-
-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Major error.py refactoring to match flake8 guidelines
Changes: 1. Fixes missing parents with `pip` installation, closes #30 2. Now respects `noqa` comments, closes #10
- Loading branch information
Showing
17 changed files
with
195 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
This file contains all possible errors. | ||
""" | ||
|
||
from .version import get_version # noqa: Z100 | ||
def some(): | ||
from my_module import some_function # noqa: Z101 | ||
|
||
|
||
del {'a': 1}['a'] # noqa: Z102 | ||
raise # noqa: Z103 | ||
raise NotImplemented # noqa: Z104 | ||
hasattr(object, 'some') # noqa: Z105 | ||
value = 1 # noqa: Z106 | ||
x = 2 # noqa: Z107 | ||
__private = 3 # noqa: Z108 | ||
__author__ = 'Nikita Sobolev' # noqa: Z109 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import subprocess | ||
|
||
|
||
def test_noqa_fixture_disabled(absolute_path): | ||
"""End-to-End test to check that all errors are present.""" | ||
filename = absolute_path('fixtures', 'noqa.py') | ||
process = subprocess.Popen( | ||
['flake8', '--disable-noqa', '--select', 'Z', filename], | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
) | ||
stdout, _ = process.communicate() | ||
|
||
assert stdout.count(b'Z') > 0 | ||
|
||
|
||
def test_noqa_fixture(absolute_path): | ||
"""End-to-End test to check that `noqa` works.""" | ||
filename = absolute_path('fixtures', 'noqa.py') | ||
process = subprocess.Popen( | ||
['flake8', '--select', 'Z', filename], | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
) | ||
stdout, _ = process.communicate() | ||
|
||
assert stdout.count(b'Z') == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 0 additions & 29 deletions
29
tests/test_visitors/test_wrong_import/test_dynamic_imports.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
This module contains ugly hacks and fixes for version compat issues. | ||
Do not be over-exited to add anything here. | ||
""" | ||
|
||
import ast | ||
|
||
|
||
def maybe_set_parent(tree: ast.AST) -> ast.AST: | ||
"""Sets parents for all nodes that do not have this prop.""" | ||
for statement in ast.walk(tree): | ||
for child in ast.iter_child_nodes(statement): | ||
if not hasattr(child, 'parent'): # noqa: Z105 | ||
setattr(child, 'parent', statement) # noqa: Z105 | ||
|
||
return tree |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.