The Python Oracle

How do I type hint a method with the type of the enclosing class?

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Drifting Through My Dreams

--

Chapters
00:00 Question
00:52 Accepted answer (Score 1475)
06:35 Answer 2 (Score 100)
07:52 Answer 3 (Score 43)
08:33 Answer 4 (Score 41)
10:35 Thank you

--

Full question
https://stackoverflow.com/questions/3353...

Accepted answer links:
[was going]: https://www.python.org/dev/peps/pep-0563/
[was reverted]: https://mail.python.org/archives/list/py.../
[PEP 563]: https://www.python.org/dev/peps/pep-0563/
[PEP 563: postponed evaluation of annotations]: https://www.python.org/dev/peps/pep-0563/
[one of the slowest python modules in core]: https://www.python.org/dev/peps/pep-0560...
[up to 7 times increase in performance]: https://docs.python.org/3.7/whatsnew/3.7...
[According to PEP 484]: https://www.python.org/dev/peps/pep-0484...
[Forward references]: https://www.python.org/dev/peps/pep-0484...
[Implementation]: https://www.python.org/dev/peps/pep-0563...
[Enabling the future behavior in Python 3.7]: https://www.python.org/dev/peps/pep-0563...

Answer 2 links:
[Self]: https://www.python.org/dev/peps/pep-0673/
https://pypi.org/project/typing-extensio.../

Answer 4 links:
[section on forward references]: https://www.python.org/dev/peps/pep-0484...
[PEP 563]: https://www.python.org/dev/peps/pep-0563/
[PEP 649]: https://www.python.org/dev/peps/pep-0649/
[PEP 673]: https://peps.python.org/pep-0673/

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #python3x #pycharm #typehinting #pythontyping

#avk47