Skip to main content

Trite hacks for use with typing.

Latest release 20260525: Sortable and EQSortable Protocols which support lt and both eq and lt respectively.

Short summary:

  • EQSortable: A type whose instances can be sorted and also tested for equality i.e.
  • is_optional: Check if annotation is an Optional[type]. Return type if so, None otherwise.
  • Sortable: A type whose instances can be sorted i.e.
  • subtype: Construct a TypeVar for subtypes of the type t.

Module contents:

  • class EQSortable(typing.Protocol): A type whose instances can be sorted and also tested for equality i.e. support the < and == operators.

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

  • class Sortable(typing.Protocol): A type whose instances can be sorted i.e. support the < operator.

  • 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 20260525: Sortable and EQSortable Protocols which support lt and both eq and lt respectively.

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 20260525

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 20260525
File Size Uploaded
cs_typingutils-20260525.tar.gz 2.1 kB Details

Built distribution (wheel)

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

Total release size: 4.7 kB

Release files / cs_typingutils-20260525.tar.gz

Download URL cs_typingutils-20260525.tar.gz
Size 2.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3ae520c9f26558fd2ef2a229fa794b3ef6732fc7389f23dea9e8868a2084a783
BLAKE2b-256 checksum
How to use checksums
d82f1766e9b372a08bfd5294648524aa6dfaa2b13b5739d144aee78e7c501f99
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-20260525-py2.py3-none-any.whl

Download URL cs_typingutils-20260525-py2.py3-none-any.whl
Size 2.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
b046a91d38b9630333cb48f9f2bb7910f4232b0f3f62aadcd640672504371de5
BLAKE2b-256 checksum
How to use checksums
6469928454e78999d302d0cab5a473927c02a81721e2ada112fc71c20bb6e9bd
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

20260525 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