This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients AlexWaygood, gvanrossum, kj, lukasz.langa, rhettinger, serhiy.storchaka
Date 2021-12-29.18:06:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1640801191.16.0.347538439319.issue46191@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-12-29 18:06:31serhiy.storchakasetrecipients: + serhiy.storchaka, gvanrossum, rhettinger, lukasz.langa, kj, AlexWaygood
2021-12-29 18:06:31serhiy.storchakasetmessageid: <1640801191.16.0.347538439319.issue46191@roundup.psfhosted.org>
2021-12-29 18:06:31serhiy.storchakalinkissue46191 messages
2021-12-29 18:06:31serhiy.storchakacreate