Skip to main content

Data Types for Cynical Humans

Project description

Typerighter

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()

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

typerighter-0.1.4.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

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

typerighter-0.1.4-py2-none-any.whl (16.1 kB view details)

Uploaded Python 2

File details

Details for the file typerighter-0.1.4.tar.gz.

File metadata

  • Download URL: typerighter-0.1.4.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for typerighter-0.1.4.tar.gz
Algorithm Hash digest
SHA256 c63ceab1ff7e7f02ec88de90568967f38cdc517663ea9128573b52478e70fdec
MD5 5c007ca1572f0a5be906024e544ddce6
BLAKE2b-256 8d7a45a36f9d9de1908189f998456cab7c34e79f8550171cafbea19e8e3fd83d

See more details on using hashes here.

File details

Details for the file typerighter-0.1.4-py2-none-any.whl.

File metadata

  • Download URL: typerighter-0.1.4-py2-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for typerighter-0.1.4-py2-none-any.whl
Algorithm Hash digest
SHA256 4f2bb8ead917859834d75b51a4b6c2c9639d5f00d0ea3e7341bce004f426c446
MD5 2209502ceb41f0bcd55b413868847f4d
BLAKE2b-256 c5e665d2a055f492fb27744360820b06c136286db662a41fde5fe9712787e283

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