On Thu, Oct 21, 2021 at 12:06 PM Jelle Zijlstra <jelle.zijls...@gmail.com> wrote:
> I would want this for my type checker, pyanalyze. I'd want to get the raw > annotation and turn it into a type. For example, if the annotation is > `List[SomeType]` and `SomeType` is imported in `if TYPE_CHECKING`, I'd at > least still be able to extract `List[Any]` instead of bailing out completely. > With some extra analysis work on the module I could even get the real type > out of the `if TYPE_CHECKING` block. If you're up for the extra analysis on the module, wouldn't it be just as possible to front-load this analysis instead of doing it after the fact, and perform the imports in the `if TYPE_CHECKING` block prior to accessing the annotation data? Or perform a fake version of the imports that just sets every name imported in `if TYPE_CHECKING` to `Any`? Carl _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/PEJBJBSFTTA4U3BXQW2N6ABGL5A4V2NF/ Code of Conduct: http://python.org/psf/codeofconduct/