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 AlexWaygood
Recipients AlexWaygood, lukasz.langa, rhettinger
Date 2021-11-05.18:53:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1636138432.76.0.213636861247.issue45684@roundup.psfhosted.org>
In-reply-to
Content
To clarify why this is an issue:

It's probably quite improbable that anybody would ever need to use `singledispatchmethod` in a type annotation. But, if they do, they'll find themselves in an impossible situation if they're using mypy with the `--strict` setting. If you're using `--strict` (as I always do), mypy will complain if you leave unparameterised any class that is marked as a generic in typeshed. But if you try to parameterise `singledispatchmethod`, and you're not using `from __future__ import annotations`, your code will fail at runtime.

It would be better if the cpython source were changed to add `__class_getitem__` to `singledispatchmethod`, rather than making the class no longer generic in typeshed. This is because being able to parameterise classes gives mypy much more information to work with, giving it the ability to provide far more fine-grained analysis of your code.

Here is a minimal reproducible example of the error mypy will give: https://mypy-play.net/?mypy=latest&python=3.10&flags=show-error-codes%2Cstrict
History
Date User Action Args
2021-11-05 18:53:52AlexWaygoodsetrecipients: + AlexWaygood, rhettinger, lukasz.langa
2021-11-05 18:53:52AlexWaygoodsetmessageid: <1636138432.76.0.213636861247.issue45684@roundup.psfhosted.org>
2021-11-05 18:53:52AlexWaygoodlinkissue45684 messages
2021-11-05 18:53:52AlexWaygoodcreate