
So does your library work both with and without ‘from __future__ import annotations’? If it does, you shouldn’t have to worry. If it doesn’t, it would be useful if you could post some detailed examples of what goes wrong. On Fri, Nov 26, 2021 at 14:24 Christopher Barker <pythonchb@gmail.com> wrote:
It's easy enough to do something at runtime with `def f(a: list[int]) -> int`. It's not so simple to handle `def f(a: Sequence[T]) -> T` or `def f(cb: (T) -> tuple[str, T], Sequence[T]) -> Mapping[str, T]`. Presumably
On Fri, Nov 26, 2021 at 1:47 PM Guido van Rossum <guido@python.org> wrote frameworks like pydantic just don't support such things and tell the user not to do that.
I don’t know about Pydantic, but that’s exactly my use case: the type needs to be an actual intstantiatable type.
So list and tuple is fine, and Sequence[t] won’t work. But it’s fine that this use case is restricted.
In fact, other than the basic core types, you need to use specialized types with this system anyway.
-CHB -- Christopher Barker, PhD (Chris)
Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython
-- --Guido (mobile)