Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

bpo-29262: Add get_origin() and get_args() introspection helpers to typing#13685

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@ilevkivskyi
Copy link
Member

@ilevkivskyiilevkivskyi commentedMay 30, 2019
edited by bedevere-bot
Loading

This is an old feature request that appears from time to time. After a year of experimenting with various introspection capabilities intyping_inspect on PyPI, I propose to add these two most commonly used functions:get_origin() andget_args(). These are essentially thin public wrappers around private APIs:__origin__ and__args__.

As discussed in the issue and on the typing tracker, exposing some public helpers instead of__origin__ and__args__ directly will give us more flexibility if we will decide to update the internal representation, while still maintaining backwards compatibility.

The implementation is very simple an is essentially a copy fromtyping_inspect with one exception:ClassVar was special-cased intyping_inspect, but I think this special-casing doesn't really help and only makes things more complicated.

https://bugs.python.org/issue29262

Copy link
Member

@gvanrossumgvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Fix the typo and land it!

@ilevkivskyiilevkivskyi merged commit4c23aff intopython:masterMay 30, 2019
@ilevkivskyiilevkivskyi deleted the add-typing-introspection branchMay 30, 2019 23:10
@saulshanabrook
Copy link
Contributor

Could you go into the rationale for normalization a bit more? I would prefer thatget_origin(typing.List[int]) is typing.List. xrefilevkivskyi/typing_inspect#36 which lays out the same issue in typing_inspect.

DinoV pushed a commit to DinoV/cpython that referenced this pull requestJan 14, 2020
…yping (pythonGH-13685)This is an old feature request that appears from time to time. After a year of experimenting with various introspection capabilities in `typing_inspect` on PyPI, I propose to add these two most commonly used functions: `get_origin()` and `get_args()`. These are essentially thin public wrappers around private APIs: `__origin__` and `__args__`.As discussed in the issue and on the typing tracker, exposing some public helpers instead of `__origin__` and `__args__` directly will give us more flexibility if we will decide to update the internal representation, while still maintaining backwards compatibility.The implementation is very simple an is essentially a copy from `typing_inspect` with one exception: `ClassVar` was special-cased in `typing_inspect`, but I think this special-casing doesn't really help and only makes things more complicated.
jstasiak added a commit to jstasiak/typing that referenced this pull requestFeb 6, 2020
The implementations come from CPython commit 427c84f13f77 with one smallchange – the get_origin's docstring mentions Annotated as it's alsosupported.get_origin() and get_args() introduced in [1] and modified in [2] tosupport Annotated.[1]python/cpython#13685[2]python/cpython#18260
gvanrossum pushed a commit to python/typing that referenced this pull requestFeb 7, 2020
The implementations come from CPython commit 427c84f13f77 with one smallchange – the get_origin's docstring mentions Annotated as it's alsosupported.get_origin() and get_args() introduced in [1] and modified in [2] tosupport Annotated.[1]python/cpython#13685[2]python/cpython#18260* Define our own get_origin()/get_args() in typing_extensions on Python 3.8Otherwise typing_extensions.get_origin() would not recognizetyping_extensions.Annotated on 3.8.
JelleZijlstra pushed a commit to python/typing_extensions that referenced this pull requestMay 19, 2022
The implementations come from CPython commit 427c84f13f77 with one smallchange – the get_origin's docstring mentions Annotated as it's alsosupported.get_origin() and get_args() introduced in [1] and modified in [2] tosupport Annotated.[1]python/cpython#13685[2]python/cpython#18260* Define our own get_origin()/get_args() in typing_extensions on Python 3.8Otherwise typing_extensions.get_origin() would not recognizetyping_extensions.Annotated on 3.8.
JelleZijlstra pushed a commit to python/typing_extensions that referenced this pull requestMay 19, 2022
The implementations come from CPython commit 427c84f13f77 with one smallchange – the get_origin's docstring mentions Annotated as it's alsosupported.get_origin() and get_args() introduced in [1] and modified in [2] tosupport Annotated.[1]python/cpython#13685[2]python/cpython#18260* Define our own get_origin()/get_args() in typing_extensions on Python 3.8Otherwise typing_extensions.get_origin() would not recognizetyping_extensions.Annotated on 3.8.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@gvanrossumgvanrossumgvanrossum approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@ilevkivskyi@saulshanabrook@gvanrossum@the-knights-who-say-ni@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp