Skip to content

Commit 01e7e80

Browse files
authored
Add types.ModuleType.__doc__ (#12918)
1 parent 7838ab5 commit 01e7e80

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

stdlib/types.pyi

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,13 @@ class ModuleType:
337337
__package__: str | None
338338
__path__: MutableSequence[str]
339339
__spec__: ModuleSpec | None
340+
# N.B. Although this is the same type as `builtins.object.__doc__`,
341+
# it is deliberately redeclared here. Most symbols declared in the namespace
342+
# of `types.ModuleType` are available as "implicit globals" within a module's
343+
# namespace, but this is not true for symbols declared in the namespace of `builtins.object`.
344+
# Redeclaring `__doc__` here helps some type checkers understand that `__doc__` is available
345+
# as an implicit global in all modules, similar to `__name__`, `__file__`, `__spec__`, etc.
346+
__doc__: str | None
340347
def __init__(self, name: str, doc: str | None = ...) -> None: ...
341348
# __getattr__ doesn't exist at runtime,
342349
# but having it here in typeshed makes dynamic imports

0 commit comments

Comments
 (0)