0

Hard to explain in title but the question is simple. How can I make this run.

class A:
    def foo(self, param: A) -> A:
        pass
  • 1
    It does run, in Python 3.10 or newer - https://www.python.org/dev/peps/pep-0563/. If you mean how can you make it pass type checking, then given that foo should return an instance of A but returns None it's tricky to square that circle. – jonrsharpe Feb 11 '21 at 22:57
  • 1
    You can use `'A'` instead. – Francis Colas Feb 11 '21 at 22:58
  • 1
    See linked dupe. `from __future__ import annotations` will sort you until 3.10+, where it just works. – tzaman Feb 11 '21 at 22:58

0 Answers0