Skip to main content

Functions for introspecting Python type hints.

Project description

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])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

type_analyzer-0.1.2.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

type_analyzer-0.1.2-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file type_analyzer-0.1.2.tar.gz.

File metadata

  • Download URL: type_analyzer-0.1.2.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for type_analyzer-0.1.2.tar.gz
Algorithm Hash digest
SHA256 da41040c171af581d9fe13eb93428e7d5c4fe855504ed0c9cddd7bc1c98b88ec
MD5 857298455fdea371a3de83cdcf312a97
BLAKE2b-256 4ddf19f07196386b904cbea7b90dd307987c4bd5d3581d7f5ca890f2698b634a

See more details on using hashes here.

File details

Details for the file type_analyzer-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: type_analyzer-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for type_analyzer-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d4ac1729583ea955875aa470da1875d611889e13541ce3ae6f8c4d43438a4028
MD5 bdb96f61cf0e7100eefed46f5e7699d1
BLAKE2b-256 eed1063cd5ff0440432aa5b1d06f6f982425cfb9176fb836ab80abd96e3507e3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page