Closed wookayin closed 1 year ago
With PEP 563 turned on, nested scope may not work properly with the previous implementation. f147b61 addresses this, adding nested scope support.
from __future__ import annotations
from typing import List, Any
global_var: List[Any]
def foo(param: List[Any]):
local_var: List[Any] = [] # <--- `List`, `Any` should be looked up from the parent symbol table
See numirias/semshi#116
PEP 563 - Postponed Evaluation of Annotations is available since python 3.7, but Semshi would throw an error when this behavior is enabled. The main point of PEP-563 is to resolve type hints at runtime; the python symbol table may not return a symbol for annotations.
Test code
See
test_postponed_evaluation_of_annotations_pep563
intest_parser.py
: