Skip to main content

Pytyp uses ABCs and function annotations in a consistent, pythonic way that supports declarative APIs - instead of saying how to do something, you have the ability to say what you want.

It includes:

  • A basic set of type specifications for describing collections of data, closely integrated into the language:

    >>> isinstance([1,2,None,4], Seq(Opt(int)))
    True
  • A decorator that type-checks functions:

    >>> def str_only(x:str): return 'foo'
    >>> str_only(42)
    Exception raised:
      ...
    TypeError: Type str inconsistent with 42.
  • A decorator that allows dynamic dispatch by type. You can combine multiple methods under one name, and then select which method is called by the type of an argument (normal OO programming uses the type of self to select the method; this is more like Lisp’s multimethods).

  • Routines for converting between Python classes and JSON or YAML. Instead of having to work with dict and list you can read JSON directly into Python classes. This is included as an example of the kind of API possible - you describe the form of the output using type specifications.

The ideas behind the library are described in more detail in Algebraic ABCs.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

pytyp-2.0.1.zip (53.9 kB view details)

Uploaded Source

pytyp-2.0.1.tar.gz (29.3 kB view details)

Uploaded Source

File details

Details for the file pytyp-2.0.1.zip.

File metadata

  • Download URL: pytyp-2.0.1.zip
  • Upload date:
  • Size: 53.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pytyp-2.0.1.zip
Algorithm Hash digest
SHA256 dde39b5574da3e1472ecb7157c83db734d4bd82d8a88c2902e157eebeb5b74d8
MD5 55a0bddeeb41ac56e42f8b6e8ff89244
BLAKE2b-256 85ecdd943e13bbaa165f6a5ca6b313f07a9bf9a929116756af702215fdf53092

See more details on using hashes here.

File details

Details for the file pytyp-2.0.1.tar.gz.

File metadata

  • Download URL: pytyp-2.0.1.tar.gz
  • Upload date:
  • Size: 29.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pytyp-2.0.1.tar.gz
Algorithm Hash digest
SHA256 7a4e22691735301ba5f3821dc56b411e90640719d1d84f9aa148832c3a5cadf4
MD5 313dabf9ea778aaaf68050dfc9aa4a7f
BLAKE2b-256 5d0b7d4774433eb45969079cf57312a5e558cf673719ca3e79b1fc094e3b270c

See more details on using hashes here.

Release history Release notifications | RSS feed

2.2.4

2 files

2.2.3

2 files

2.2.2

2 files

2.2.1

2 files

2.2

2 files

This release

2.0.1 This release

2 files

2.0

2 files

1.1

2 files

1.0.2

2 files

1.0.1

2 files

1.0

2 files

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