You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This breaks the current implementation of multipledispatch.dispatch():
from __future__ importannotationsimportmultipledispatch@multipledispatch.dispatch()deffunc(x):
raiseNotImplementedError(x)
@multipledispatch.dispatch()deffunc(x: int):
returnf"x {x} int"print(func(1))
Traceback (most recent call last):
File "/home/user/tmp/single.py", line 11, in <module>
@multipledispatch.dispatch()
File "/home/user/.local/pipx/venvs/ipython/lib/python3.7/site-packages/multipledispatch/core.py", line 68, in _
dispatcher.add(types, func)
File "/home/user/.local/pipx/venvs/ipython/lib/python3.7/site-packages/multipledispatch/dispatcher.py", line 225, in add
(typ, str_sig, self.name))
TypeError: Tried to dispatch on non-type: int
In signature: <int>
In function: func
Annotations are becoming string-valued by default in a future version. This feature is accessible in Python 3.7 with
from __future__ import annotations
.This breaks the current implementation of
multipledispatch.dispatch()
:The solution that
functools.singledispatch
uses is to calltyping.get_type_hints()
to evaluate the hint strings.The text was updated successfully, but these errors were encountered: