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/

Reply via email to