Skip to main content

Trite hacks for use with typing.

Project description

Trite hacks for use with typing.

Latest release 20250503: is_optional: bugfix: Optional[T] has a get_args of (T,), not (T,None).

Short summary:

  • is_optional: Check if annotation is an Optional[type]. Return type if so, None otherwise.
  • subtype: Construct a TypeVar for subtypes of the type t.

Module contents:

  • is_optional(annotation): Check if annotation is an Optional[type]. Return type if so, None otherwise.

  • subtype(t, name=None): Construct a TypeVar for subtypes of the type t.

    Parameters:

    • t: the type which bounds the TypeVar
    • name: optional name for the TypeVar, default t.__name__ + 'SubType'

Release Log

Release 20250503: is_optional: bugfix: Optional[T] has a get_args of (T,), not (T,None).

Release 20250428: New is_optional(annotation) function to recognise Optional[type] annotations, returning type if true, None otherwise.

Release 20230331: Initial release.

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

cs_typingutils-20250503.tar.gz (1.8 kB view details)

Uploaded Source

Built Distribution

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

cs_typingutils-20250503-py2.py3-none-any.whl (2.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file cs_typingutils-20250503.tar.gz.

File metadata

  • Download URL: cs_typingutils-20250503.tar.gz
  • Upload date:
  • Size: 1.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for cs_typingutils-20250503.tar.gz
Algorithm Hash digest
SHA256 b9c402f83bb467a654b5e83c70e74bd356ca332aca2f30b413b45e48f31c4bc8
MD5 4c64ac809c1dd3a3c84b394e20c779cd
BLAKE2b-256 597a29271ce15cdaa2974a63092a399846de0b99063f23297ef83b1be98252a7

See more details on using hashes here.

File details

Details for the file cs_typingutils-20250503-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for cs_typingutils-20250503-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 26962aa0aed9dd5899ec83b2be788840c5eb1fe0ac72118dfdcc879b4f8d88f0
MD5 4e2af2892d4afaf0a8e7585055ad6967
BLAKE2b-256 cc77fbc5d4893758d2fc53324a420b0a9d53cc2913472113e225a9ec8e2b8515

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