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

Uploaded Python 3

File details

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

File metadata

  • Download URL: typestr-0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 1acc941b9e44d95169022547f1351f75e4b81633ee93dbb7f9cb56d573292375
MD5 85a833bfcb22b1ce7a4a5a516d56bee1
BLAKE2b-256 04b98c7962371f92e1a0b7f7e4074eb2c6c3ebf42b69e5cbb3ba09e3f6b67e8a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typestr-0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 916ce7b18edbba947faaa04b1d72dd36f4a00acdb423e49fd70bb568b5e6a88a
MD5 15d287a0b3acd84c3706bc3eddb09e93
BLAKE2b-256 baee208fc3afad4db56094899d1fd853e3b1eb1dc0518799bcf604da75c39074

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