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 glyph
Recipients glyph
Date 2020-10-09.20:11:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1602274303.54.0.362260014367.issue41987@roundup.psfhosted.org>
In-reply-to
Content
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?
History
Date User Action Args
2020-10-09 20:11:43glyphsetrecipients: + glyph
2020-10-09 20:11:43glyphsetmessageid: <1602274303.54.0.362260014367.issue41987@roundup.psfhosted.org>
2020-10-09 20:11:43glyphlinkissue41987 messages
2020-10-09 20:11:43glyphcreate