-
Notifications
You must be signed in to change notification settings - Fork 237
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
Add PEP 673 Self type #933
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). Recognized GitHub usernameWe couldn't find a bugs.python.org (b.p.o) account corresponding to the following GitHub usernames: This might be simply due to a missing "GitHub Name" entry in one's b.p.o account settings. This is necessary for legal reasons before we can look at this contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
For reference: @pradeep90 has also signed the CLA according to https://check-python-cla.herokuapp.com/. |
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.
Thanks. Please also add an entry to typing_extensions/CHANGELOG
.
What should be done test wise for this? |
I'd say have a look at the existing tests in |
I'm not entirely clear as to why the 3.6/7 tests fail? Is typing extensions being in the venv being preferred over the local version? |
That's weird indeed. Even if the venv version was preferred, it should fail in Python 3.8+ as well. Edit: But yes, it's trying to import |
Is the problem that something else in the venv is also installing typing-extensions? Maybe we can try explicitly uninstalling it before running the tests. |
Yes, it's because |
So put |
Better to just run it in the GitHub action directly. |
I've just merge #932, so there are conflicts now, but I think they should be easy to fix. |
Hm, that doesn't work either because apparently our copy of typing-extensions isn't on the $PATH yet when we try to import pytest. Possible ideas:
|
I would prefer the first approach but it might be better to do it in a separate PR. I can do that tonight if nobody else gets to it first. For reference this is the deptree:
We'll also have to get rid of flake8, probably by running linting in a different venv from testing. |
I think this is the best idea. We can run flake8 in a separate job, so that it installing typing-extensions shouldn't matter. |
typing-extensions is widely enough used that it seems really easy for this to be reintroduced. We can leave a big warning, but another approach to consider is putting |
I'm hoping that we just won't have any dependencies in the tests. This seems achievable because that's what the stdlib does, and typing-extensions is essentially a back/forwardported piece of stdlib. |
#935 hopefully fixes CI. |
Hello, Would it be possible to use this for nested classes?
|
This isn't the right place to ask questions about the PEP (see the python-dev mailing list for that). But for what it's worth the PEP states Self should be evaluated in the enclosing class's (Z) namespace so Self.A would attribute error if this were possible but to me this doesn't make much sense and it would be a big change to both the PEP and the implementation to add support for this at runtime. NB. I don't mind the idea of allowing attribute access on types/type aliases in the class namespace. This is something that rust does although you might just be better off making your class generic to work around this. |
Adds support for PEP 673 and the special form
Self
, pyright already assumes this is here so it would be good to get runtime support for this.Co-authored-by: Pradeep Kumar Srinivasan gohanpra@gmail.com
@pradeep90