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.1.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.1-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: typestr-0.3.1.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.1.tar.gz
Algorithm Hash digest
SHA256 95edb9f595fca978b75b9c61756735f9e5290ca70ea18028ff94d54591b64681
MD5 364462cf5fcd65ef85b2202c6913e938
BLAKE2b-256 6e8a268fa2fff91608f39289b99641e75315b87c09cd3671fea41431c40a7e53

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typestr-0.3.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9f342e4149099f20c813ddf2dc7b00f9b1d74bb81d6c27dc0e7e9b2460000781
MD5 91aff226f7aaf869e7d679e5438cf3ba
BLAKE2b-256 f807b6432b6dbe2a28fa7ea77f10d8902d7b15bfa7d7bb1c116ef527b4b5bbd1

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