[issue46032] functools' singledispatch does not support GenericAlias

2021-12-26 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue46032] functools' singledispatch does not support GenericAlias

2021-12-26 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset 25a12aac4de819745dfc64664ba183a5784b5a81 by Miss Islington (bot) in branch '3.9': [3.9] bpo-46032: Check types in singledispatch's register() at declaration time (GH-30050) (GH-30254) (GH-30255)

[issue46032] functools' singledispatch does not support GenericAlias

2021-12-25 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset 03c7449fbc7c57f5e0365f234a0b65c1dde763f2 by Serhiy Storchaka in branch '3.10': [3.10] bpo-46032: Check types in singledispatch's register() at declaration time (GH-30050) (GH-30254)

[issue46032] functools' singledispatch does not support GenericAlias

2021-12-25 Thread miss-islington
Change by miss-islington : -- nosy: +miss-islington nosy_count: 6.0 -> 7.0 pull_requests: +28476 pull_request: https://github.com/python/cpython/pull/30255 ___ Python tracker

[issue46032] functools' singledispatch does not support GenericAlias

2021-12-25 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- pull_requests: +28475 pull_request: https://github.com/python/cpython/pull/30254 ___ Python tracker ___

[issue46032] functools' singledispatch does not support GenericAlias

2021-12-25 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset 078abb676cf759b1e960f78390b6e80f256f0255 by Serhiy Storchaka in branch 'main': bpo-46032: Check types in singledispatch's register() at declaration time (GH-30050)

[issue46032] functools' singledispatch does not support GenericAlias

2021-12-11 Thread Alex Waygood
Change by Alex Waygood : -- components: +Documentation type: enhancement -> behavior ___ Python tracker ___ ___ Python-bugs-list

[issue46032] functools' singledispatch does not support GenericAlias

2021-12-11 Thread Alex Waygood
Alex Waygood added the comment: The PR looks good to me. I think it's also important that we document that these types aren't supported, as it's not mentioned anywhere at the moment. Related: Issue34498. -- nosy: +uriyyo ___ Python tracker

[issue46032] functools' singledispatch does not support GenericAlias

2021-12-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Yes, it is related to issue45665. It is a complicated case due to coincidence of several circumstances. 1. isinstance(list[int], type) is True, while isinstance(typing.List[int], type) is False. list[int] is considered a type in this check. 2.

[issue46032] functools' singledispatch does not support GenericAlias

2021-12-11 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- keywords: +patch pull_requests: +28275 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30050 ___ Python tracker

[issue46032] functools' singledispatch does not support GenericAlias

2021-12-10 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- assignee: -> serhiy.storchaka nosy: +serhiy.storchaka ___ Python tracker ___ ___ Python-bugs-list

[issue46032] functools' singledispatch does not support GenericAlias

2021-12-10 Thread Alex Waygood
Alex Waygood added the comment: The above traceback is because the `isinstance(list[str], type)` check at Lib/functools.py:848 evaluates to `True`. Related: #45665. -- ___ Python tracker

[issue46032] functools' singledispatch does not support GenericAlias

2021-12-10 Thread Alex Waygood
Alex Waygood added the comment: It would be well worth it to improve the error message, however: ``` >>> from functools import singledispatch >>> @singledispatch ... def func(arg): ... raise NotImplementedError ... >>> @func.register ... def _(arg: list[str]): ... print('Got a list

[issue46032] functools' singledispatch does not support GenericAlias

2021-12-10 Thread Alex Waygood
Alex Waygood added the comment: My opinion is that supporting `GenericAlias` here would be a bad idea. Associating an implementation of the function with the argument type `list[str]` is ambiguous. Would this implementation be called if any argument of type `list` was supplied, or would it

[issue46032] functools' singledispatch does not support GenericAlias

2021-12-10 Thread Kumar Aditya
New submission from Kumar Aditya : functools' singledispatch does not support GenericAlias ```py from functools import singledispatch @singledispatch def func(x): print("any") @func.register def _(x: list[str]): print("list[str]") func(["a", "b"]) ``` -- components: