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

2022-04-25 Thread Mehdi2277
The forward class annotations would not need need to be processed at runtime and could be no-ops. forward class A: x: int y: list[int] A.__annotations__ could be empty. For a more complete example you could have, forward class A: value: B # This annotation is solely for type checker and

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

2022-04-25 Thread Mehdi2277
The problem comes solely from runtime introspection of type annotations. Static typing does not need this nor do any exceptional cases occur. From mypy/pyright/other type checker perspective there is not an issue to solve here. dataclasses, pydantic, cattrs, click, and other libraries that

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

2022-04-25 Thread Mehdi2277
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

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

2022-04-23 Thread Mehdi2277
My main question for this approach is how would this work with type checkers? Is there any restriction that forward class's continuation must appear in same module? If it's allowed that a forward class may be continued in a different module I do not see how type checker like mypy/pyright could

[Python-Dev] Re: RFC on Callable Syntax PEP

2021-12-20 Thread Mehdi2277
I don’t see how this helps much in situations with nested callables which are very common for decorators. I’m also unsure how this will work with situations where input and output are both callables and the signature is modified using paramspec. An example would be a decorator that adds/removes

[Python-Dev] Re: PEP-646 question: unpacking into single Generic parameter

2021-09-24 Thread Mehdi2277
I don't believe this is supported in pep 646 today. It was originally going to be supported with a Map operator. With a Map operator it would let you do something like, T = TypeVar('T') Ts = TypeVarTuple("Ts") IndexedTuple = Tuple[Int, T] def enumerage_args(*args: *Ts) -> *Map[IndexedTuple,