Skip to content

Commit 67688df

Browse files
authored
Report undefined module attributes with --ignore-missing-imports (python#7372)
The issue was reported internally. Currently we never report missing module attributes with `--ignore-missing-imports`.
1 parent 811647f commit 67688df

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

mypy/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2347,7 +2347,7 @@ def find_module_and_diagnose(manager: BuildManager,
23472347

23482348

23492349
def exist_added_packages(suppressed: List[str],
2350-
manager: BuildManager, options: Options) -> bool:
2350+
manager: BuildManager, options: Options) -> bool:
23512351
"""Find if there are any newly added packages that were previously suppressed.
23522352
23532353
Exclude everything not in build for follow-imports=skip.

mypy/semanal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3982,7 +3982,7 @@ def get_module_symbol(self, node: MypyFile, name: str) -> Optional[SymbolTableNo
39823982
return sym
39833983

39843984
def is_missing_module(self, module: str) -> bool:
3985-
return self.options.ignore_missing_imports or module in self.missing_modules
3985+
return module in self.missing_modules
39863986

39873987
def implicit_symbol(self, sym: SymbolTableNode, name: str, parts: List[str],
39883988
source_type: AnyType) -> SymbolTableNode:

test-data/unit/check-modules.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2755,3 +2755,13 @@ roles.role = 1 # E: Incompatible types in assignment (expression has type "int"
27552755
from types import ModuleType
27562756
def __getattr__(name: str) -> ModuleType: ...
27572757
[builtins fixtures/module.pyi]
2758+
2759+
[case testAlwaysReportMissingAttributesOnFoundModules]
2760+
# flags: --ignore-missing-imports
2761+
import pack.mod as alias
2762+
2763+
x: alias.NonExistent # E: Name 'alias.NonExistent' is not defined
2764+
2765+
[file pack/__init__.py]
2766+
[file pack/mod.py]
2767+
class Existent: pass

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy