PEP 484 forward references should be quoted? · Issue #180 · python/typeshed (original) (raw)

PEP 484 mentions that forward references should be quoted:

class Tree: def init(self, left: 'Tree', right: 'Tree'): self.left = left self.right = right

This convention doesn't seem to be followed in the typeshed stubs, for instance, from datetime:

class date: @classmethod def fromtimestamp(cls, t: float) -> date: ...

Not sure whether the PEP is ambiguous (maybe this isn't necessary in stub files?) or whether this is an error. I realize mypy has no trouble parsing these, but I'm wondering about other type checkers. The latest version of PyCharm, for instance, cannot resolve a stub written this way (see https://youtrack.jetbrains.com/issue/PY-19374).