Type-checking module for Python
This package provides powerful run-time typechecking facilities for Python functions, methods and generators.
Without requiring a custom preprocessor or alterations to the language, the typecheck
package allows programmers and quality assurance engineers to make precise assertions about the input to, and output from, their code.
News
typecheck 0.3.5 Released
28 May 2006 - just pushed out to PyPI, typecheck
0.3.5 is a bugfix release.
This is intended to give people a solid base to work on while adapting to all the changes that typecheck
0.4.0 will be introducing.
Development Documentation Now Online
26 Apr 2006 - to complement the bleeding-edge code available from typecheck
's SVN repository, the development branch of the documentation is now available via the Interwebnet.
We do our best to keep the development docs in line with the latest changes in the repository, meaning this is the best way to learn about some of the new features scheduled for the upcoming 0.4 release.
typecheck 0.3.4 Released
22 Jan 2006 - the latest release of the typecheck
package adds the concept of typeclasses, a way of grouping types and classes based on related functionality.
Also included are a set of starter typeclasses, designed to address everyday, real-world typechecking scenarios:
- ImSequence - immutable sequences
- Mapping - the mapping interface
- MSequence - mutable sequences
- Number - numeric types
- String - string types
Check out the introduction to typeclasses and the docs for the Typeclass() utility class for more information.
Tutorial
While the typecheck
package isn't particularly complicated or complex, it does take some getting used to.
To ease your transition into the wonderful world of typechecked progamming, we've put together a comprehensive tutorial, covering everything you need to know to get started using this project.
New to typechecking? We suggest beginning at the beginning.
Lesson 1 - Basic Typechecking - how to make sure your functions get the right parameters and return the right things.
Lesson 2 - Built-in Types - learn about expressing complex types using Python's built-in datatypes.
Lesson 3 - Utility Classes - explore typecheck's
library of utilities that allow you to make complex, precise assertions about types.
Lesson 4 - Typechecking Methods - all you ever wanted to know about adding typechecking to your instance-, class- and staticmethods.
Lesson 5 - Generators - writing generators may be tricky, but typechecking them sure isn't.
Lesson 6 - Typechecking Best Practices - tips, tricks and sage counsel from the typechecking trenches.
Advanced Topics
Type Variables - all about type variables, a concept borrowed from languages like Haskell.
Doctest Support - learn how to make your typechecked code play nicely with the doctest
module.
Using Functions for Complex Typing - in addition to the built-in utility classes, you can pass functions and methods to the typechecking decorators, allowing powerful, custom typing behaviour. Learn how.
Manual
What follows is a reference manual to the various cogs and sprockets that go together to make typecheck
what it is.
We start out with a dive into the utility classes, then explore deeper still into the darkest corners of the package's core machinery.
Utility Classes
- Introduction to Utility Classes
Boolean Expressions
Miscellaneous
Typeclasses
- Introduction to Typeclasses
- ImSequence - immutable sequences
- Mapping - the mapping interface
- MSequence - mutable sequences
- Number - numeric types
- String - string types