osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Type hinting


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