[Python-Dev] Re: Proto-PEP part 1: Forward declaration of classes

2022年4月25日 18:26:07 -0700

On 4/25/2022 9:13 PM, Mehdi2277 wrote:
We could have forward part include all of method signatures/attributes which is 
what a type checker needs. In theory we could do,
forward class Foo:
 x: int
 y: list[str]
def __init__(self, ...)
 def process(self, data: list[float]) -> float: ...
and then later do continue class. If we're willing to write a full header 
equivalent of c++ then I think static typing side will work. It'll be a lot 
more verbose then normal that I'd probably pick other solutions, but I it 
should make it tractable for a type checker.
How would this address the use case presented in the original post?
class A:
  value: B
class B:
  value: A
Eric
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/2CPE3IB7TUJKEAY633LS3WM7PRQ7R6L6/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to