-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Implementation of PEP 673 (typing.Self) #11666
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
acf87a3
Much better initial implementation of typing.Self
Gobot1234 7a6d771
Some extra stuff
Gobot1234 b1d67ca
Slight improvements
Gobot1234 c09d95f
Merge branch 'master' into master
Gobot1234 6a7a084
Remove removed type
Gobot1234 2ac45c9
Update meet.py
Gobot1234 1ebe034
Update mypy/type_visitor.py
Gobot1234 0e6d128
Fix most of the CI issues and respond to comments
Gobot1234 f844fbe
Merge branch 'master' of https://github.com/Gobot1234/mypy
Gobot1234 5904918
Merge remote-tracking branch 'upstream/master'
Gobot1234 e932f52
Merge branch 'master' into master
Gobot1234 ff779e8
I think this works properly now
Gobot1234 f94254f
Merge branch 'master' of https://github.com/Gobot1234/mypy
Gobot1234 c9b2ac9
Merge branch 'master' into master
Gobot1234 ad0b9b0
Merge remote-tracking branch 'origin/master' into gobot-master
erikkemperman 6766132
Make tests pass
erikkemperman cada36a
Unit tests
erikkemperman 68c1339
Merge pull request #1 from erikkemperman/gobot-master
Gobot1234 46d8b70
Merge remote-tracking branch 'upstream/master'
Gobot1234 fb6d552
I don't think this is entirely correct but lets see
Gobot1234 6c71758
Fix tests
Gobot1234 791c9e3
Fixes for signatures of form (type[Self]/Self) -> Self
Gobot1234 09e966e
Fix some CI
Gobot1234 ce2d5fa
Fix some CI failures
Gobot1234 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
Fix most of the CI issues and respond to comments
- Loading branch information
commit 0e6d128bbd00952b4ea3e5434c1ec1a91108c943
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
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
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import sys | ||
|
||
from mypy.version import __version__ | ||
from mypy.build import build, BuildSource, Options | ||
|
||
print(__version__) | ||
|
||
options = Options() | ||
options.show_traceback = True | ||
options.raise_exceptions = True | ||
options.verbosity = 10 | ||
result = build([BuildSource("test.py", None, )], options, stderr=sys.stderr, stdout=sys.stdout) | ||
print(*result.errors, sep="\n") |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Self, TypeVar, Protocol | ||
|
||
T = TypeVar("T") | ||
|
||
|
||
class InstanceOf(Protocol[T]): | ||
@property # type: ignore | ||
def __class__(self) -> T: ... # type: ignore | ||
|
||
|
||
class MyMetaclass(type): | ||
bar: str | ||
|
||
def __new__(mcs: type[MyMetaclass], *args, **kwargs) -> MyMetaclass: | ||
cls = super().__new__(mcs, *args, **kwargs) | ||
cls.bar = "Hello" | ||
return cls | ||
|
||
def __mul__( | ||
cls, | ||
count: int, | ||
) -> list[InstanceOf[Self]]: | ||
print(cls) | ||
return [cls()] * count | ||
|
||
def __call__(cls, *args, **kwargs) -> InstanceOf[Self]: | ||
return super().__call__(*args, **kwargs) | ||
|
||
|
||
class Foo(metaclass=MyMetaclass): | ||
THIS: int | ||
|
||
reveal_type(Foo) | ||
reveal_type(Foo()) | ||
foos = Foo * 3 | ||
reveal_type(foos) |
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.