Skip to main content

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.

Release files for cs-typingutils 20250503

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cs-typingutils 20250503
File Size Uploaded
cs_typingutils-20250503.tar.gz 1.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cs-typingutils 20250503
File Interpreter ABI Platform
cs_typingutils-20250503-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 4.1 kB

Release files / cs_typingutils-20250503.tar.gz

Download URL cs_typingutils-20250503.tar.gz
Size 1.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b9c402f83bb467a654b5e83c70e74bd356ca332aca2f30b413b45e48f31c4bc8
BLAKE2b-256 checksum
How to use checksums
597a29271ce15cdaa2974a63092a399846de0b99063f23297ef83b1be98252a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / cs_typingutils-20250503-py2.py3-none-any.whl

Download URL cs_typingutils-20250503-py2.py3-none-any.whl
Size 2.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
26962aa0aed9dd5899ec83b2be788840c5eb1fe0ac72118dfdcc879b4f8d88f0
BLAKE2b-256 checksum
How to use checksums
cc77fbc5d4893758d2fc53324a420b0a9d53cc2913472113e225a9ec8e2b8515
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release history Release notifications | RSS feed

This release

20250503 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page