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.0.tar.gz (6.2 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.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: type_analyzer-0.1.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"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.0.tar.gz
Algorithm Hash digest
SHA256 37b419a1da5199fceb99c5a59688ce2081d881d2f21b144849fd38614a010efa
MD5 b91f3b3828dd21fa4988d36bff6c58d0
BLAKE2b-256 42cf80d1859b0438c1c844088c3fc4f74a53348de54da7d76e7928ec526d1a5e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: type_analyzer-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e36e0ccfb4be26ece9a832a194be8b689be5b9e7361493b06bbbc0d6ba66992e
MD5 1e2c35a177a2b4aa830c900881e3ebf9
BLAKE2b-256 28c2eba125f357066048068a2073f158dfaf47e3a8a8175e645ab3fc43be80e0

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