-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Fix new style union syntax in type aliases #14008
Merged
Merged
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5856657
Fix new style union syntax in type aliases
JukkaL 76b543d
Cleaner representation for special forms in error messages
JukkaL b11b023
Fix some tests
JukkaL 8c57be5
Suggest adding a suitable fixture
JukkaL 06d0c8d
Add functools test fixture
JukkaL 5a79c20
Fix functools fixture
JukkaL 5438a2e
Update comment
JukkaL 6adab4e
Update test case
JukkaL 6726101
Update test case
JukkaL 967a2cc
Test syntax in stubs with older Python version
JukkaL 0d7bfa1
Update test case
JukkaL f359e72
Add more test stubs
JukkaL 893a918
Fix mypyc test case
JukkaL de9c391
Fix test case
JukkaL 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
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from typing import Generic, TypeVar, Callable, Any, Mapping | ||
|
||
_T = TypeVar("_T") | ||
|
||
class _SingleDispatchCallable(Generic[_T]): | ||
registry: Mapping[Any, Callable[..., _T]] | ||
def dispatch(self, cls: Any) -> Callable[..., _T]: ... | ||
# @fun.register(complex) | ||
# def _(arg, verbose=False): ... | ||
@overload | ||
def register(self, cls: type[Any], func: None = ...) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ... | ||
# @fun.register | ||
# def _(arg: int, verbose=False): | ||
@overload | ||
def register(self, cls: Callable[..., _T], func: None = ...) -> Callable[..., _T]: ... | ||
# fun.register(int, lambda x: x) | ||
@overload | ||
def register(self, cls: type[Any], func: Callable[..., _T]) -> Callable[..., _T]: ... | ||
def _clear_cache(self) -> None: ... | ||
def __call__(__self, *args: Any, **kwargs: Any) -> _T: ... | ||
|
||
def singledispatch(func: Callable[..., _T]) -> _SingleDispatchCallable[_T]: ... | ||
|
||
def total_ordering(cls: type[_T]) -> type[_T]: ... | ||
|
||
class cached_property(Generic[_T]): | ||
func: Callable[[Any], _T] | ||
attrname: str | None | ||
def __init__(self, func: Callable[[Any], _T]) -> None: ... | ||
@overload | ||
def __get__(self, instance: None, owner: type[Any] | None = ...) -> cached_property[_T]: ... | ||
@overload | ||
def __get__(self, instance: object, owner: type[Any] | None = ...) -> _T: ... | ||
def __set_name__(self, owner: type[Any], name: str) -> None: ... | ||
def __class_getitem__(cls, item: Any) -> Any: ... |
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some tests were using the typeshed stub for
functools
, and it requirestyping._SpecialForm
. Instead of adding a bunch oftyping-medium.pyi
fixtures, I decided to create a simplified stub to use in tests. This also speeds up the test cases a bit.