New submission from Glyph Lefkowitz <gl...@twistedmatrix.com>:
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? ---------- components: Library (Lib) messages: 378346 nosy: glyph priority: normal severity: normal stage: needs patch status: open title: singledispatchmethod raises an error when relying on a forward declaration type: behavior versions: Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue41987> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com