Data Types for Cynical Humans
Overview
Welcome to Typerighter, a project that makes it easy to with common types of data using roughly the same ideas as type systems. Instead of defining what a string is, it uses strings to define what URLs or datetimes are.
Its concepts are simple and built around ideas that require little effort for effective data management.
Schematics Rethink
I am the original author of https://github.com/schematics/schematics.
A community took over the Schematics project a while back, but I found I needed to solve the roughly the same validation and conversion problems in every new system I encountered, giving me an opportunity to continue learning about the problem space.
Typerighter is how I think about the problem ten years after Schematics.
Read The Docs
Learn more about it with our great documentation.
Example
Define a type by instantiating it with config parameters.
>>> string_type = types.StringType(max_length=12)
Validate data with that type definition.
>>> short_string = 'Take Five'
>>> string_type.validate(short_string)
Define a record with fields and instantiate it.
>>> class Artist(types.Record):
... name = types.StringType(required=True)
... website = types.URLType()
...
>>> artist_type = Artist()
Validate data with that record.
>>> band_data = {
... 'name': u'American Food',
... 'website': 'https://soundcloud.com/americanfood'
... })
>>> artist_type.validate(band_data)
Use a mutable structure instead of a dict for the data.
>>> american_food = artist_type.make_view(band_data)
>>> # Promote the reinterpretation of Take On Me
>>> american_food.website = 'https://soundcloud.com/americanfood/my-take-on-take-on-me'
>>> american_food.validate()
Metadata
Release files for typerighter 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| typerighter-0.2.0.tar.gz | 13.3 kB | Details |
Release files / typerighter-0.2.0.tar.gz
| Download URL | typerighter-0.2.0.tar.gz |
|---|---|
| Size | 13.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1bad18d08573fb6616017645759c321b6d55b7af9e24897812a440f337f6e086
|
|
BLAKE2b-256 checksum How to use checksums |
049935ea9803a4a3307d69c26f9662fe5943eef1cf1c4d94ffe5c3e341b6dd43
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.2
|