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.1.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

typing_tool-0.1.1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: typing_tool-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 e4c849920b34fe3a24e530604debffe11116131167350564cb9a48a1cf1de7df
MD5 500ade3d8fc0f374d8c8aed51eba8b79
BLAKE2b-256 5cbb8d043b48c80cf09ae4edc49d0aab23b4d6be66070546d1e9f7c436e1a971

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typing_tool-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 482228fe9512a88834acc0818dd3279f4d9ade1d821930ccf4b34c6abf668d4e
MD5 901c1b57317b9007211ef0c765d1076d
BLAKE2b-256 25cb919b00776bc3f9343e7eff925067ef234d035f8641324fd9e95d5d1d9052

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