Trite hacks for use with typing.
Project description
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 ifannotationis anOptional[type]. Returntypeif so,Noneotherwise.Sortable: A type whose instances can be sorted i.e.subtype: Construct aTypeVarfor subtypes of the typet.
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 ifannotationis anOptional[type]. Returntypeif so,Noneotherwise. -
class Sortable(typing.Protocol): A type whose instances can be sorted i.e. support the<operator. -
subtype(t, name=None): Construct aTypeVarfor subtypes of the typet.Parameters:
t: the type which bounds theTypeVarname: optional name for theTypeVar, defaultt.__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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cs_typingutils-20260525.tar.gz.
File metadata
- Download URL: cs_typingutils-20260525.tar.gz
- Upload date:
- Size: 2.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ae520c9f26558fd2ef2a229fa794b3ef6732fc7389f23dea9e8868a2084a783
|
|
| MD5 |
34e583445e9d3dfd58124243130dcec9
|
|
| BLAKE2b-256 |
d82f1766e9b372a08bfd5294648524aa6dfaa2b13b5739d144aee78e7c501f99
|
File details
Details for the file cs_typingutils-20260525-py2.py3-none-any.whl.
File metadata
- Download URL: cs_typingutils-20260525-py2.py3-none-any.whl
- Upload date:
- Size: 2.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b046a91d38b9630333cb48f9f2bb7910f4232b0f3f62aadcd640672504371de5
|
|
| MD5 |
1579c9cc665dc1f2a8e812088ada0e00
|
|
| BLAKE2b-256 |
6469928454e78999d302d0cab5a473927c02a81721e2ada112fc71c20bb6e9bd
|