Human-readable type strings for Python
Project description
pytypestr
Human-readable type strings for Python.
Single-file, zero-dependency utility for rendering Python type hints into clean, modern signatures.
Usage
from typing import Literal
from typestr import render_function, render_type
def foo(x: int | None, y: list[str]) -> bool:
pass
print(render_function(foo))
print(render_type(
list[
Literal[200, 300, 400]
| tuple[str | int, str, dict[str, int | float], ...]
]
))
Output:
(x: int?, y: list<str>) -> bool
list<200 | 300 | 400 | (str | int, str, dict<str, int | float>, ...)>
Features
-
Modern
UnionsyntaxUnion[A, B]→A | B -
Modern
LiteralsyntaxLiteral[A, B, ...]→A | B | ... -
Tuple formatting
tuple[A, B, ...]→(A, B, ...) -
Generic types
list[A]→list<A> -
Optional shorthand
Optional[A]→A? -
Callable signatures
Callable[[A], B]→(A) -> B -
Built-in container types support
License
MIT
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 typestr-0.1.0.tar.gz.
File metadata
- Download URL: typestr-0.1.0.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2320a5eb62c2fdb19414d0f7e09c6bc29043ce9d7e8ed7f91a5c7ae93e449c2d
|
|
| MD5 |
9568ac28aa50f7a1ae99b5434f89ccbc
|
|
| BLAKE2b-256 |
c3ab6aade8d533b088d808ce03c5acb25ff6c128ef3214066c793c4710810222
|
File details
Details for the file typestr-0.1.0-py3-none-any.whl.
File metadata
- Download URL: typestr-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0ffc63e2b0fcf7fc1883d604cf3e02f8728268ceb7154a94fa1cc045e578eb8
|
|
| MD5 |
58bdd03063e54f105a45ffef101c4376
|
|
| BLAKE2b-256 |
3425716832c4ec74d00ea319d301fa19b14cb2bc507a788e39885d329b11eb01
|