1

How would I do typing for the following?

class Scope:
    def __init__(self, parent: Optional[Scope] = None) -> None:
        self.parent = Scope

Scope can receive a parent scope. In C I would do something like:

struct Env {
    struct Env parent;
    ...
};

Or provide a forward declaration. How would this be done in python's typing? Otherwise I just get a straight error:

NameError: name 'Scope' is not defined

samuelbrody1249
  • 4,379
  • 1
  • 15
  • 58

0 Answers0