Skip to main content

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

PyPI: https://pypi.org/project/typestr/0.1.0/

pip install typestr
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 Union syntax Union[A, B]A | B

  • Modern Literal syntax Literal[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

typestr-0.3.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

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

typestr-0.3-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file typestr-0.3.tar.gz.

File metadata

  • Download URL: typestr-0.3.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for typestr-0.3.tar.gz
Algorithm Hash digest
SHA256 075fb85b2ee7220df58b74ba0ddf274500076cdb041ddd577db10d53a908dee2
MD5 e0164666d7e73c98400b8d016f8f0899
BLAKE2b-256 e7a628dc0c4507d95170929118351c34d6e3bd6e8790d76cfd9de3ea6a9032fd

See more details on using hashes here.

File details

Details for the file typestr-0.3-py3-none-any.whl.

File metadata

  • Download URL: typestr-0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for typestr-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 11daf775bb255b1251b5c6d5c156b49f13086c3e74cdd869d9e6fff608852f40
MD5 9f8e987bfb6df9bffb3391f8ca45e291
BLAKE2b-256 39d35c83007d314a5bb5112a8fa9ed418617b18c24d6298b8e01906eab9fdf0b

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