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 declarative 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.

Note that you must also install PyYAML if you want to encode/decode YAML.

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.2.2.zip (6.0 kB view details)

Uploaded Source

pytyp-2.2.2.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file pytyp-2.2.2.zip.

File metadata

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

File hashes

Hashes for pytyp-2.2.2.zip
Algorithm Hash digest
SHA256 2ba4e15f0d2c951117e92872019dceb16871b7f1bedc900029b0472799467813
MD5 ad027908b15128ec75c151184d01f599
BLAKE2b-256 945814e8a1faca00945b7537d4de93abac5e70a867838c72b1816c5e0f1c1821

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pytyp-2.2.2.tar.gz
Algorithm Hash digest
SHA256 9a7982223aca31abf110a576975160299f99b095aa8af041a3abc2c8a97215fa
MD5 a70fd560ae6eac47347fc6fbdfa36dc4
BLAKE2b-256 199ea6f95c5b9d1bdf7e00ec75552d31042eeac300c37e51603c726c8a0a1d9b

See more details on using hashes here.

Release history Release notifications | RSS feed

2.2.4

2 files

2.2.3

2 files

This release

2.2.2 This release

2 files

2.2.1

2 files

2.2

2 files

2.0.1

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