Add types.ModuleType.__doc__ (#12918)

This commit is contained in:
Alex Waygood
2024-10-29 14:09:47 +00:00
committed by GitHub
parent 7838ab5f98
commit 01e7e80bc7

View File

@@ -337,6 +337,13 @@ class ModuleType:
__package__: str | None
__path__: MutableSequence[str]
__spec__: ModuleSpec | None
# N.B. Although this is the same type as `builtins.object.__doc__`,
# it is deliberately redeclared here. Most symbols declared in the namespace
# of `types.ModuleType` are available as "implicit globals" within a module's
# namespace, but this is not true for symbols declared in the namespace of `builtins.object`.
# Redeclaring `__doc__` here helps some type checkers understand that `__doc__` is available
# as an implicit global in all modules, similar to `__name__`, `__file__`, `__spec__`, etc.
__doc__: str | None
def __init__(self, name: str, doc: str | None = ...) -> None: ...
# __getattr__ doesn't exist at runtime,
# but having it here in typeshed makes dynamic imports