Skip to content

Commit

Permalink
Add types.ModuleType.__doc__ (#12918)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood authored Oct 29, 2024
1 parent 7838ab5 commit 01e7e80
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions stdlib/types.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 01e7e80

Please sign in to comment.