Message409313
I do not think there is a problem in MyPy. What if use __origin__ for dispatching? Registering with parametrized generics with the same __origin__ will be error.
@sigledispatch
def f(a: int) -> None:
pass
@f.register # ok
def _(a: list[int]) -> None:
pass
@f.register # runtime error
def _(a: list[str]) -> None:
pass
@f.register # runtime error
def _(a: list) -> None:
pass
f(1) # ok
f([1]) # ok
f([]) # ok
f(['abc']) # static type checking error
I think that it will have advantage of stronger static type checking. |
|
Date |
User |
Action |
Args |
2021-12-29 18:06:31 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, gvanrossum, rhettinger, lukasz.langa, kj, AlexWaygood |
2021-12-29 18:06:31 | serhiy.storchaka | set | messageid: <1640801191.16.0.347538439319.issue46191@roundup.psfhosted.org> |
2021-12-29 18:06:31 | serhiy.storchaka | link | issue46191 messages |
2021-12-29 18:06:31 | serhiy.storchaka | create | |
|