Skip to main content

typeset for Python

Semantic field types: email, phone, URL, money, locale, cron, ISBN, GeoJSON and the rest of 97 types. Each one turns messy input into one canonical value, refuses everything else with a clear message, and describes itself so you can build forms, schemas and type pickers from it.

This is the Python twin of the npm package @chadc00per/typeset: both store the same input as the same value and refuse it with the same message, held to one shared conformance suite. Validate in the browser and again in a Python backend, and compare the results directly.

pip install "chadc00per-typeset[all]"   # or [phone], [code], or no extras: see below
import chadc00per_typeset as typeset

typeset.Email(' Ada@Example.COM ')         # → 'ada@example.com'
typeset.Phone.normalize('(212) 555-0123')  # → '+12125550123'
typeset.Money('12.5 usd')['amount']        # → '12.50'
typeset.Email.is_('nope')                  # → False
typeset.Email.check('nope', 'user.email')  # → {'ok': False, 'issues': [{'path': 'user.email', 'message': 'must be a valid email address', 'code': 'invalid'}]}
typeset.Email.normalize('nope')            # → raises ValidationError: email must be a valid email address
typeset.to_json_schema('uint8')['maximum'] # → 255
signup = typeset.struct({'email': typeset.Email, 'zip': 'postalcode'})
[i['message'] for i in signup.check({'email': 'x'})['issues']]  # → ['must be a valid email address', 'must be a valid postal code']

Values are the plain values themselves (str, int or float, tuple, or a read-only dict), immutable and hashable, and they serialize with json.dumps. Each type is also a Pydantic field type. The extras: [phone] adds phone numbers (phonenumbers) and [code] the javascript, python, html, css and svg types (an embedded V8 running the npm package's own parsers); without one, those types raise ModuleNotFoundError naming it.

The full guide, including the JavaScript-to-Python name table, is the main README.

Apache-2.0 (with third-party material under its own licenses; see NOTICE). Report vulnerabilities privately: see SECURITY.md.

Metadata

Release files for chadc00per-typeset 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chadc00per-typeset 1.0.0
File Size Uploaded Provenance Actions
chadc00per_typeset-1.0.0.tar.gz 414.9 kB Without provenance Details for chadc00per_typeset-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for chadc00per-typeset 1.0.0
File Interpreter ABI Platform Actions
chadc00per_typeset-1.0.0-py3-none-any.whl Python 3 none any Details for chadc00per_typeset-1.0.0-py3-none-any.whl

Total release size: 757.9 kB

Release files / chadc00per_typeset-1.0.0.tar.gz

Download URL chadc00per_typeset-1.0.0.tar.gz
Size 414.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a19a6e6c6e2e7717c450235b12e13071249acb3c8c3364e882fa1ab2b9b2a430
BLAKE2b-256 checksum
How to use checksums
9a8a84c6b711d22decb43f4be611831d48d0519f01a420b36168eaa6bc9639f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / chadc00per_typeset-1.0.0-py3-none-any.whl

Download URL chadc00per_typeset-1.0.0-py3-none-any.whl
Size 342.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
140bb8237846f664e858df254f6995fb8f5cf88f24f3cc2bde910025bd51a968
BLAKE2b-256 checksum
How to use checksums
335e02c1b64504eece68d8c142def2f4ce6e07077f44ab2d350d955088c60cd3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for chadc00per-typeset 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page