How would runtime consumers of annotations use this? -- Eric
On Apr 26, 2022, at 12:05 PM, Thomas Kehrenberg <tmke@posteo.net> wrote:
If the problem is mostly type annotations, then another potential solution would be to make use of .pyi files, which are not hamstrung by circular definitions. The idea would be that type checkers would merge the annotations from .pyi files into the annotations in the corresponding .py file.
So:
a.py:
from b import B
class A: value: B
b.py:
class B: value = None
b.pyi:
from typing import Optional from a import A
class B: value: Optional[A] = ...
The pyi files would kind of act like header files that are used in other languages. It would mean that type checkers need to check the .pyi files against the code in the .py files to verify that they're consistent with one another.
-thomas _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@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/VWPWN5KW... Code of Conduct: http://python.org/psf/codeofconduct/