Skip to content
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

Implement proposed "Self" type #2515

Closed
erictraut opened this issue Oct 30, 2021 · 1 comment
Closed

Implement proposed "Self" type #2515

erictraut opened this issue Oct 30, 2021 · 1 comment
Labels
addressed in next version Issue is fixed and will appear in next published version enhancement request New feature or request

Comments

@erictraut
Copy link
Collaborator

A new PEP for Python 3.11 proposes to introduce a new special form called Self exported from the typing module.

https://docs.google.com/document/d/1ujuSMXDmSIOJpiZyV7mvBEC8P-y55AgSzXcvhrZciuI/edit

Pyright already implements this in an implicit manner, inferring the type of self and cls parameters when they are unannotated, so it should be easy to prototype this new functionality.

@erictraut erictraut added enhancement request New feature or request addressed in next version Issue is fixed and will appear in next published version labels Oct 30, 2021
@erictraut
Copy link
Collaborator Author

This is addressed in pyright 1.1.184, which I just published. It will also be included in the next release of pylance.

crux14 added a commit to akashi-org/akashi that referenced this issue Nov 25, 2021
For library codes, Pyright' type inference does not work properly. This commit addresses the issue. If typing.Self is implemented in the future, we could handle such cases in an easier way.

https://www.python.org/dev/peps/pep-0673/
microsoft/pyright#2515
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version enhancement request New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant