diff --git a/lib/python/pyflyby/_autoimp.py b/lib/python/pyflyby/_autoimp.py index e2f5a93f..5689bf16 100644 --- a/lib/python/pyflyby/_autoimp.py +++ b/lib/python/pyflyby/_autoimp.py @@ -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): diff --git a/tests/test_autoimp.py b/tests/test_autoimp.py index 9fe0cf55..45f6c458 100644 --- a/tests/test_autoimp.py +++ b/tests/test_autoimp.py @@ -521,7 +521,6 @@ def foo(): assert unused == [] - def test_find_missing_imports_class_name_1(): code = dedent( """