Thanks to visit codestin.com
Credit goes to github.com

Skip to content

inspect.getmember docs do not mention __type_params__ for functions and classes #116782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sobolevn opened this issue Mar 14, 2024 · 1 comment
Closed
Assignees
Labels
docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

sobolevn commented Mar 14, 2024

Bug report

Docs do not mention __type_params__ key returned value for classes and functions:

+===========+===================+===========================+
| class | __doc__ | documentation string |
+-----------+-------------------+---------------------------+
| | __name__ | name with which this |
| | | class was defined |
+-----------+-------------------+---------------------------+
| | __qualname__ | qualified name |
+-----------+-------------------+---------------------------+
| | __module__ | name of module in which |
| | | this class was defined |
+-----------+-------------------+---------------------------+
| method | __doc__ | documentation string |
+-----------+-------------------+---------------------------+
| function | __doc__ | documentation string |
+-----------+-------------------+---------------------------+
| | __name__ | name with which this |
| | | function was defined |
+-----------+-------------------+---------------------------+
| | __qualname__ | qualified name |
+-----------+-------------------+---------------------------+
| | __code__ | code object containing |
| | | compiled function |
| | | :term:`bytecode` |
+-----------+-------------------+---------------------------+
| | __defaults__ | tuple of any default |
| | | values for positional or |
| | | keyword parameters |
+-----------+-------------------+---------------------------+
| | __kwdefaults__ | mapping of any default |
| | | values for keyword-only |
| | | parameters |
+-----------+-------------------+---------------------------+
| | __globals__ | global namespace in which |
| | | this function was defined |
+-----------+-------------------+---------------------------+
| | __builtins__ | builtins namespace |
+-----------+-------------------+---------------------------+
| | __annotations__ | mapping of parameters |
| | | names to annotations; |
| | | ``"return"`` key is |
| | | reserved for return |
| | | annotations. |
+-----------+-------------------+---------------------------+
| | __module__ | name of module in which |
| | | this function was defined |
+-----------+-------------------+---------------------------+
| traceback | tb_frame | frame object at this |

But, they are returned:

>>> class A[T]: ...
... 
>>> import inspect
>>> dict(inspect.getmembers(A))['__type_params__']
(T,)

I will send a PR for that.

Linked PRs

@sobolevn sobolevn added type-bug An unexpected behavior, bug, or error docs Documentation in the Doc dir stdlib Python modules in the Lib dir labels Mar 14, 2024
@sobolevn sobolevn self-assigned this Mar 14, 2024
sobolevn added a commit to sobolevn/cpython that referenced this issue Mar 14, 2024
sobolevn added a commit that referenced this issue Mar 15, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Mar 15, 2024
…cs (pythonGH-116783)

(cherry picked from commit 1634986)

Co-authored-by: Nikita Sobolev <[email protected]>
Co-authored-by: Jelle Zijlstra <[email protected]>
sobolevn added a commit that referenced this issue Mar 15, 2024
…ocs (GH-116783) (#116870)

gh-116782: Mention `__type_params__` in `inspect.getmembers` docs (GH-116783)
(cherry picked from commit 1634986)

Co-authored-by: Nikita Sobolev <[email protected]>
Co-authored-by: Jelle Zijlstra <[email protected]>
@hugovk
Copy link
Member

hugovk commented Mar 15, 2024

Triage: can this issue be closed?

vstinner pushed a commit to vstinner/cpython that referenced this issue Mar 20, 2024
adorilson pushed a commit to adorilson/cpython that referenced this issue Mar 25, 2024
diegorusso pushed a commit to diegorusso/cpython that referenced this issue Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants