Message378346
This example:
from __future__ import annotations
from functools import singledispatchmethod
class Comparable:
@singledispatchmethod
def compare(self, arg: object):
raise NotImplementedError("what")
@compare.register
def _(self, arg: Comparable):
return "somewhat similar"
print(Comparable().compare(Comparable()))
Produces this result:
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/typing.py", line 518, in _evaluate
eval(self.__forward_code__, globalns, localns),
File "<string>", line 1, in <module>
NameError: name 'Comparable' is not defined
It seems like perhaps singledispatchmethod should defer its type evaluation to its first invocation? |
|
Date |
User |
Action |
Args |
2020-10-09 20:11:43 | glyph | set | recipients:
+ glyph |
2020-10-09 20:11:43 | glyph | set | messageid: <1602274303.54.0.362260014367.issue41987@roundup.psfhosted.org> |
2020-10-09 20:11:43 | glyph | link | issue41987 messages |
2020-10-09 20:11:43 | glyph | create | |
|