This PEP [1] introduces a simple and intuitive way to annotate methods and 
classmethods that return an instance of their class. Such methods and 
classmethods occur quite frequently, but the existing way to annotate them 
correctly is quite arcane and error-prone. The PEP introduces a special type 
`Self` to represent the type of the `self` parameter, similar to the `this` 
type in TypeScript and the `Self` type in Rust. We have implementations for 
mypy and pyright. The PEP does not affect CPython directly except for the 
addition of one special form (Self) to typing.py [2]. 

Since we have reached consensus on the PEP in typing-sig [3], we wanted to get 
your comments and suggestions before submitting to the Steering Council.

Thanks,
Pradeep Kumar Srinivasan
James Hilton-Balfe

[1]: https://www.python.org/dev/peps/pep-0673/
[2]: Adding `Self` to typing_extensions.py: 
https://github.com/python/typing/pull/933
[3]: See the comments from typing-sig members on the Google doc: 
https://docs.google.com/document/d/1ujuSMXDmSIOJpiZyV7mvBEC8P-y55AgSzXcvhrZciuI/edit?usp=sharing
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/G4F3ZMCJRWWRSF7O34Z7RPYQQK7QPGB6/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to