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

gh-112618: MakeAnnotated cache typed#112619

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
AlexWaygood merged 9 commits intopython:mainfromsobolevn:issue-112618
Dec 2, 2023
Merged
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Rename type
  • Loading branch information
@sobolevn
sobolevn committedDec 2, 2023
commit03b43b3215dc80cd7756e6e3b9a85b9c84d4771b
13 changes: 3 additions & 10 deletionsLib/typing.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -490,14 +490,7 @@ def __getitem__(self, parameters):
return self._getitem(self, parameters)


class _LiteralSpecialForm(_SpecialForm, _root=True):
def __getitem__(self, parameters):
if not isinstance(parameters, tuple):
parameters = (parameters,)
return self._getitem(self, *parameters)


class _AnnotatedSpecialForm(_SpecialForm, _root=True):
class _TypedCacheSpecialForm(_SpecialForm, _root=True):
def __getitem__(self, parameters):
if not isinstance(parameters, tuple):
parameters = (parameters,)
Expand DownExpand Up@@ -730,7 +723,7 @@ def Optional(self, parameters):
arg = _type_check(parameters, f"{self} requires a single type.")
return Union[arg, type(None)]

@_LiteralSpecialForm
@_TypedCacheSpecialForm
@_tp_cache(typed=True)
def Literal(self, *parameters):
"""Special typing form to define literal types (a.k.a. value types).
Expand DownExpand Up@@ -2012,7 +2005,7 @@ def __mro_entries__(self, bases):
return (self.__origin__,)


@_AnnotatedSpecialForm
@_TypedCacheSpecialForm
@_tp_cache(typed=True)
def Annotated(self, *params):
"""Add context-specific metadata to a type.
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp