Skip to content

Commit

Permalink
Bidirectional submodule import exception
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvdb committed May 4, 2016
1 parent 2a698f8 commit 2ba836a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pyflakes/checker.py
Expand Up @@ -142,6 +142,8 @@ def __init__(self, name, source, full_name=None):
super(Importation, self).__init__(name, source)

def redefines(self, other):
if isinstance(other, SubmoduleImportation):
return self.fullName == other.fullName
return isinstance(other, Definition) and self.name == other.name

def _has_alias(self):
Expand Down
6 changes: 6 additions & 0 deletions pyflakes/test/test_imports.py
Expand Up @@ -767,6 +767,12 @@ def test_used_package_with_submodule_import(self):
fu.x
''')

self.flakes('''
import fu.bar
import fu
fu.x
''')

def test_unused_package_with_submodule_import(self):
"""
When a package and its submodule are imported, only report once.
Expand Down

0 comments on commit 2ba836a

Please sign in to comment.