Skip to content

Commit

Permalink
remove missing import even if its inside class
Browse files Browse the repository at this point in the history
  • Loading branch information
aktech committed Oct 17, 2023
1 parent af04c6e commit e2b384b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/python/pyflyby/_autoimp.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,13 +878,13 @@ def _visit_Store(self, fullname, value=None):
def _remove_from_missing_imports(self, fullname):
for missing_import in self.missing_imports:
# If it was defined inside a class method, then it wouldn't have been added to
# the missing imports anyways.
# the missing imports anyways (except in that case of annotations)
# See the following tests:
# - tests.test_autoimp.test_method_reference_current_class
# - tests.test_autoimp.test_find_missing_imports_class_name_1
# - tests.test_autoimp.test_scan_for_import_issues_class_defined_after_use
inside_class = missing_import[1].scope_info.get('_in_class_def')
if missing_import[1].startswith(fullname) and not inside_class:
if missing_import[1].startswith(fullname):
self.missing_imports.remove(missing_import)

def _get_scope_info(self):
Expand Down
1 change: 0 additions & 1 deletion tests/test_autoimp.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,6 @@ def foo():
assert unused == []



def test_find_missing_imports_class_name_1():
code = dedent(
"""
Expand Down

0 comments on commit e2b384b

Please sign in to comment.