Skip to main content

python typing tool

Project description

typing_tool

Typing_Tool 是一个 Python 类型工具

CodeFactor GitHub CodeQL

功能

安装

pip install typing_tool

Or

pdm add typing_tool

入门指南

typing_tool 是一个用于增强 Python 类型检查能力的工具库。特别地,它扩展了 isinstance 和 issubclass 函数的能力,使其能够处理更复杂的类型检查需求。

支持类型

like_isinstance

  • 基础类型 str/int/...
  • 容器泛型 list[T]/dict[K, V]/...
  • Union 类型类型
  • Type
  • TypeVar 类型变量
  • 泛型类 Generic[T]
  • Annotated/Field 注解类型
  • Protocol 协议类型
  • Protocol[T] 泛型协议类型
  • TypedDict 字典类型
  • dataclass 数据类
  • dataclass[T] 泛型数据类

like_issubclass

  • 基础类型 str/int
  • 容器泛型 list[T]/dict[K, V]
  • Union 类型类型
  • NewType 新类型
  • Type
  • TypeVar 类型变量
  • 泛型类 Generic[T]
  • Protocol 协议类型
  • Protocol[T] 泛型协议类型

Check Config

  • depth: 设置类型检查的最大深度
  • max_sample: 设置最大采样数
  • protocol_type_strict: 是否严格检查 Protocol 类型
  • dataclass_type_strict: 是否严格检查 dataclass 类型

注意

  • NewType 无法在运行时进行 like_isinstance

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

typing_tool-0.1.2.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

typing_tool-0.1.2-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: typing_tool-0.1.2.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.19.1 CPython/3.10.12 Linux/6.8.0-1014-azure

File hashes

Hashes for typing_tool-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9a1e16b523e0c7cb7ce4545ead7c3fe4f528518c36c8d79bd0df5afd18f927c6
MD5 103c865402e8ffdcbc0744fe27286c4a
BLAKE2b-256 cae1dccd0d8e94d496b6709becdafdf1066e481d00d421c1a0aed0857006a31f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typing_tool-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.19.1 CPython/3.10.12 Linux/6.8.0-1014-azure

File hashes

Hashes for typing_tool-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 39375142aaed54e71e597fa4a93323ff42586d8567b4e52c5e75f815a04be262
MD5 dc08fec88063c8c9e8e795bb657a2bd5
BLAKE2b-256 8866dcb0b65dbfe4266d032a90f0fd435cf948810aaaa54a1b1c433f2e017ca0

See more details on using hashes here.

Supported by

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