Documentation
The __module__ attribute doesn't have a proper entry in the docs. It is only documented in the context of specific object types, as an attribute. Would it make sense to give its own entry?
Moreover, its description is inconsistent across the documentation:
| Attribute |
Description |
Suggestion |
| definition.__module__ |
The name of the module in which a class or function was defined. |
Add "or None if unavailable"? |
| function.__module__ |
The name of the module the function was defined in, or None if unavailable. |
✔️ |
| method.__module__ |
The name of the module the method was defined in, or None if unavailable. |
✔️ |
| type.__module__ |
The name of the module in which the class was defined. |
Add "or None if unavailable`? |
| typing.NewType.__module__ |
The module in which the new type is defined. |
Say "the name of the module", add "or None if unavailable"? |
| typing.TypeAliasType.__module__ |
The module in which the type alias was defined: |
Say "the name of the module", add "or None if unavailable"? |
(links found via this search: https://docs.python.org/3/search.html?q=__module__)
I come from this issue mkdocstrings/griffe#419, where a user reports that the __module__ attribute of an object seems to be an actual instance of module rather than just its (qualified) name, and I wonder if someone made a mistake when creating the object dynamically due to the docs being unclear.
Also, and more importantly, I just wanted to make sure what the specification is, whether __module__ should only ever be a string or None, or can be a module instance. The description for NewType and TypeAliasType make it seem like it can be a module.
Happy to send a PR to normalize the descriptions 🙂
Linked PRs
Documentation
The
__module__attribute doesn't have a proper entry in the docs. It is only documented in the context of specific object types, as an attribute. Would it make sense to give its own entry?Moreover, its description is inconsistent across the documentation:
Noneif unavailable"?Noneif unavailable.Noneif unavailable.Noneif unavailable`?Noneif unavailable"?Noneif unavailable"?(links found via this search: https://docs.python.org/3/search.html?q=__module__)
I come from this issue mkdocstrings/griffe#419, where a user reports that the
__module__attribute of an object seems to be an actual instance of module rather than just its (qualified) name, and I wonder if someone made a mistake when creating the object dynamically due to the docs being unclear.Also, and more importantly, I just wanted to make sure what the specification is, whether
__module__should only ever be a string orNone, or can be a module instance. The description forNewTypeandTypeAliasTypemake it seem like it can be a module.Happy to send a PR to normalize the descriptions 🙂
Linked PRs
__module__description in typing.rst #139863__module__description in typing.rst (GH-139863) #139869__module__description in typing.rst (GH-139863) #139870