Skip to content

InvestmentSystems/typing-resolver

Repository files navigation

https://img.shields.io/github/actions/workflow/status/InvestmentSystems/typing-resolver/test.yml?branch=default&label=test&logo=Github

Overview

typing-resolver provides a more helpful alternative to typing.get_type_hints() by resolving type annotations using a reconstructed import namespace. It is intended for codebases that rely on TYPE_CHECKING imports, conditional imports, or inherited annotations that might not be present at runtime.

Problem

typing.get_type_hints() evaluates annotations in a limited namespace. If an annotation references a name that is not imported at runtime (for example, under if TYPE_CHECKING:), resolution fails with NameError.

Solution

This package rebuilds a local namespace by collecting ALL import statements from inside ALL module(s) in an type object's MRO and uses that namespace when resolving type hints.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages