Type hinting

Joseph L. Casale jcasale at activenetwerx.com
Mon Apr 8 12:02:36 EDT 2019


Hi,
Is it possible to associate combinations of types for a given signature, for example:

T = TypeVar('T', Foo, Bar, Baz)
S = TypeVar('S', FooState, BarState, BazState)

closure = 'populated dynamically'

def foo(factory: Callable[[List[T], str], None], state: S) -> List[T]:
    results = []
    factory(results, closure)
    return results

When T is Foo, S must be FooState etc.

Is that possible with the current implementation?

Thanks,
jlc



More information about the Python-list mailing list