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.3.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.3-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: type_analyzer-0.1.3.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","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.3.tar.gz
Algorithm Hash digest
SHA256 b4d4d815ce97d5b02baa48f24b4352674dad8e50170d4a26fd22ce3534846b5e
MD5 06fc8e0ba4fa7f57a398ee454512e01e
BLAKE2b-256 86828cdac5b7559a32ea1b6d052b58eaba59662955ae7307d10eadca4a77fe23

See more details on using hashes here.

File details

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

File metadata

  • Download URL: type_analyzer-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 33b0df7006f071dbf6a72ef124d66d58ee9f81d072d4d5adaa73fe4e2132d69b
MD5 edd31c600c3aee80072532a5cbd443fd
BLAKE2b-256 974d9cc2cdc844167e14ee5a3f3e16db7df225499aecd9cfa3a804778f974e23

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