Skip to main content

A Python 3 easy to use runtime typechecker

Project description

typecheck3
===

An easy-to-use Python 3 runtime typechecker.

Usage
---

The typical usage for this decorator would be something like this:

@typecheck
def foo(i: int) -> bool:
return a > 0

@typecheck
def to_int(*, s: by_regex("^[0-9]+$")) -> int:
return int(s)

@typecheck
def set_debug_level(self, level: optional(one_of(1, 2, 3)) = 2):
self._level = level

This recipe is extensible with callable predicates, such as

is_even = lambda x: x % 2 == 0

@typecheck
def multiply_by_2(i: int) -> is_even:
return i * 2

Credits
---

The code was written by Dmitri Dvoinikov and maintained by Esteban Ordano
(@eordano on twitter).

Original link:

http://code.activestate.com/recipes/572161/

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

typecheck3-0.1.0-py3.3.egg (1.4 kB view details)

Uploaded Egg

File details

Details for the file typecheck3-0.1.0-py3.3.egg.

File metadata

File hashes

Hashes for typecheck3-0.1.0-py3.3.egg
Algorithm Hash digest
SHA256 6dc777b12402f45e0a0bd355dbce455976618afbc5f3d235affe8d9f393cc08e
MD5 9c136a6cdb0ad97200d03554f128b8f0
BLAKE2b-256 87352f4f5eeea4ac99348e549e380989b3be8d5c37751690236e693ed2082a70

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