Skip to main content

PyTreaty is a hard fork of the PyContracts library from Andrea Censi. This fork has been updated to allow multiple contract definitions on a function, as well as removing Python 2.x support and other updates.

Project description

Build Status codecov Codacy Badge


This is a hard fork of the PyContracts library, the original version of which can be found here.

Modifications we have made:

  • All contract definitions are now applied at all times. Previously if you added type annotations to a function, the docstring contracts were ignored. Type annotations and docstring contracts have different (but overlapping) purposes, and therefore we require both. Also, previously if you used a contract decorator then both type annotations and docstring contracts were ignored. This is also fixed.
  • Removed Python 2.x support. Maintaining support for legacy python versions bloats the codebase significantly, so we only support Python 3.5+.

Why did we fork?

We are big fans of the original project from Andrea Censi, and we are very happy to merge these changes upstream, however we received no response from the original project, and therefore we assume the project is orphaned.

There are also wider changes we want to make across the codebase, so we also crossed the threshold where it became viable to maintain our own codebase.

Thing to come

We plan to continue to improve and support PyTreaty, some notable future improvements that are planned are:

  • Adding support for complex Python typing and custom type hints.
  • New and improved documentation.

Project details

Download files

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

Files for pytreaty, version 2019.1b5
Filename, size File type Python version Upload date Hashes
Filename, size pytreaty-2019.1b5-py3-none-any.whl (58.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pytreaty-2019.1b5.tar.gz (41.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page