-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Add get_origin annotations #9811
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
Changes from 8 commits
87e8f58
da99bd6
44fe739
870ee63
1ebef53
f274e90
6718114
001adb2
887bf5b
130d3f7
7b2b9cb
7456d4d
0014633
6b791a4
012db9f
faa6646
cdede57
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,11 @@ from typing import ( # noqa: Y022,Y039 | |
| type_check_only, | ||
| ) | ||
|
|
||
| if sys.version_info >= (3, 10): | ||
| from types import UnionType | ||
| if sys.version_info >= (3, 9): | ||
| from types import GenericAlias | ||
|
|
||
| __all__ = [ | ||
| "Any", | ||
| "ClassVar", | ||
|
|
@@ -155,7 +160,21 @@ def get_type_hints( | |
| include_extras: bool = False, | ||
| ) -> dict[str, Any]: ... | ||
| def get_args(tp: Any) -> tuple[Any, ...]: ... | ||
| def get_origin(tp: Any) -> Any | None: ... | ||
|
|
||
| if sys.version_info >= (3, 10): | ||
| @overload | ||
| def get_origin(tp: ParamSpecArgs | ParamSpecKwargs) -> ParamSpec: ... | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, actually, this overload can work on 3.7+ for (py37) C:\Users\alexw\coding\typeshed>python
Python 3.7.16 (default, Jan 17 2023, 16:06:28) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from typing_extensions import ParamSpec, get_origin
>>> type(get_origin(ParamSpec("P").args))
<class 'typing_extensions.ParamSpec'>
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will take care of it later today. Thanks! |
||
| @overload | ||
| def get_origin(tp: UnionType) -> type[UnionType]: ... | ||
|
|
||
| if sys.version_info >= (3, 9): | ||
| @overload | ||
| def get_origin(tp: GenericAlias) -> type: ... | ||
| @overload | ||
| def get_origin(tp: Any) -> Any | None: ... | ||
|
|
||
| else: | ||
| def get_origin(tp: Any) -> Any | None: ... | ||
|
zmievsa marked this conversation as resolved.
Outdated
|
||
|
|
||
| Annotated: _SpecialForm | ||
| _AnnotatedAlias: Any # undocumented | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.