Skip to content

100nm/type-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

type-analyzer

CI PyPI - Version PyPI - Downloads Ruff

Installation

⚠️ Requires Python 3.12 or higher

pip install type-analyzer

Quick start

matching_types

from type_analyzer import MatchingTypesConfig, matching_types

# ----- Union type -----

matching_types(str | int)
# => (str, int)

# ----- Generic type alias -----

type StringOr[T] = str | T

config = MatchingTypesConfig(with_type_alias_value=True)
matching_types(StringOr[int], config)
# => (StringOr[int], str, int)

# ----- Generic classes -----

class A[T]:
    ...

class B[T]:
    ...

class C[T1, T2](A[T1], B[T2]):
    ...

config = MatchingTypesConfig(with_bases=True)
matching_types(C[str, int], config)
# => (C[str, int], A[str], B[int])

About

Functions for introspecting Python type hints.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •