-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Add support for PEP 661 (sentinels) #21454
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
Draft
JelleZijlstra
wants to merge
7
commits into
python:master
Choose a base branch
from
JelleZijlstra:sentinels
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c641321
Add support for PEP 661 (sentinels)
JelleZijlstra 4d00721
simplify
JelleZijlstra 271a07c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 190b7c5
test isinstance
JelleZijlstra cfa09f4
Fix sentinel cache restore
JelleZijlstra 835bb3b
maybe fix
JelleZijlstra a2caece
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
simplify
- Loading branch information
commit 4d00721893f73aac635b20d76ef8920a218183f9
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,60 +1,21 @@ | ||
| # Builtins stub used in sentinel-related test cases. | ||
|
|
||
| import _typeshed | ||
| import types | ||
| from typing import Iterable, Iterator, TypeVar, Generic, Sequence, Optional, overload, Tuple, Type, Self | ||
|
|
||
| _T = TypeVar("_T") | ||
| _Tco = TypeVar('_Tco', covariant=True) | ||
| from typing import Self | ||
|
|
||
| class object: | ||
| def __init__(self) -> None: pass | ||
| def __new__(cls) -> Self: ... | ||
|
|
||
| class type: | ||
| def __init__(self, *a: object) -> None: pass | ||
| def __call__(self, *a: object) -> object: pass | ||
| class tuple(Sequence[_Tco], Generic[_Tco]): | ||
| def __hash__(self) -> int: ... | ||
| def __new__(cls: Type[_T], iterable: Iterable[_Tco] = ...) -> _T: ... | ||
| def __iter__(self) -> Iterator[_Tco]: pass | ||
| def __contains__(self, item: object) -> bool: pass | ||
| @overload | ||
| def __getitem__(self, x: int) -> _Tco: pass | ||
| @overload | ||
| def __getitem__(self, x: slice) -> Tuple[_Tco, ...]: ... | ||
| def __mul__(self, n: int) -> Tuple[_Tco, ...]: pass | ||
| def __rmul__(self, n: int) -> Tuple[_Tco, ...]: pass | ||
| def __add__(self, x: Tuple[_Tco, ...]) -> Tuple[_Tco, ...]: pass | ||
| def count(self, obj: object) -> int: pass | ||
| class type: pass | ||
| class function: | ||
| __name__: str | ||
| class ellipsis: pass | ||
| class classmethod: pass | ||
|
|
||
| # We need int and slice for indexing tuples. | ||
| class int: | ||
| def __neg__(self) -> 'int': pass | ||
| def __pos__(self) -> 'int': pass | ||
| class float: pass | ||
| class slice: pass | ||
| class int: pass | ||
| class bool(int): pass | ||
| class str: pass # For convenience | ||
| class str: pass | ||
|
|
||
| class sentinel: | ||
| def __init__(self, name: str, /) -> None: ... | ||
| class bytes: pass | ||
| class bytearray: pass | ||
|
|
||
| class list(Sequence[_T], Generic[_T]): | ||
| @overload | ||
| def __getitem__(self, i: int) -> _T: ... | ||
| @overload | ||
| def __getitem__(self, s: slice) -> list[_T]: ... | ||
| def __contains__(self, item: object) -> bool: ... | ||
| def __iter__(self) -> Iterator[_T]: ... | ||
|
|
||
| def isinstance(x: object, t: type) -> bool: pass | ||
|
|
||
| class BaseException: pass | ||
|
|
||
| class dict: pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.