1

I started using annotations recently. I have a singleton instance, hence I have a get_instance method whose return value has the same type of the class the method belongs to.

class Singleton(object):
    def __init__(self):
        pass
    def get_instance(self) -> Singleton:  # Obviously the interpreter complains about undefined name
        pass

What is the correct way to annotate the get_instance method?

Dimitris Fasarakis Hilliard
  • 150,925
  • 31
  • 268
  • 253
se7entyse7en
  • 4,310
  • 7
  • 33
  • 50

0 Answers0