Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed May 20, 2024
1 parent 830db42 commit 50d0897
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,10 @@ def add_implicit_module_attrs(self, file_node: MypyFile) -> None:
return
typ = inst
elif name == "__spec__":
inst: Type | None = self.named_type_or_none("importlib.machinery.ModuleSpec")
if self.options.use_builtins_fixtures:
inst = self.named_type_or_none("builtins.object")
else:
inst = self.named_type_or_none("importlib.machinery.ModuleSpec")
if inst is None:
if self.final_iteration:
inst = self.named_type_or_none("builtins.object")
Expand Down
8 changes: 8 additions & 0 deletions test-data/unit/pythoneval.test
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,22 @@ f
[case testModuleAttributes]
import math
import typing
print(type(__spec__))
print(math.__name__)
print(math.__spec__.name)
print(type(math.__spec__.loader))
print(type(math.__dict__))
print(type(math.__doc__ or ''))
print(type(math.__spec__))
print(math.__class__)
[out]
<class 'NoneType'>
math
math
<class '_frozen_importlib_external.ExtensionFileLoader'>
<class 'dict'>
<class 'str'>
<class '_frozen_importlib.ModuleSpec'>
<class 'module'>

[case testSpecialAttributes]
Expand Down

0 comments on commit 50d0897

Please sign in to comment.