> On Apr 26, 2022, at 3:05 PM, Thomas Kehrenberg <t...@posteo.net> wrote: > > > Apr 26, 2022 20:32:55 Eric V. Smith <e...@trueblade.com>: > >> How would runtime consumers of annotations use this? >> >> -- >> Eric >> >>>> On Apr 26, 2022, at 12:05 PM, Thomas Kehrenberg <t...@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-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/VWPWN5KWTRPP6VS4PEHJA4SRVMUDU5WR/ >>> Code of Conduct: http://python.org/psf/codeofconduct/ > They wouldn't. But I thought PEP 649 solves the runtime problems, > and that the remaining problems are with static typing > of circular definitions.
If the class needs access to its own type annotations at runtime (for example, if it’s a dataclass), then the circular reference problem still exists with PEP 649. That’s among the cases we’re trying to resolve. Eric _______________________________________________ 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/SV37AN7HYQNAVIE2BMJ5C5AC77FENTCS/ Code of Conduct: http://python.org/psf/codeofconduct/