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:

  1. ImSequence - immutable sequences
  2. Mapping - the mapping interface
  3. MSequence - mutable sequences
  4. Number - numeric types
  5. 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.

  1. Lesson 1 - Basic Typechecking - how to make sure your functions get the right parameters and return the right things.

  2. Lesson 2 - Built-in Types - learn about expressing complex types using Python's built-in datatypes.

  3. Lesson 3 - Utility Classes - explore typecheck's library of utilities that allow you to make complex, precise assertions about types.

  4. Lesson 4 - Typechecking Methods - all you ever wanted to know about adding typechecking to your instance-, class- and staticmethods.

  5. Lesson 5 - Generators - writing generators may be tricky, but typechecking them sure isn't.

  6. Lesson 6 - Typechecking Best Practices - tips, tricks and sage counsel from the typechecking trenches.

  7. Advanced Topics

    1. Type Variables - all about type variables, a concept borrowed from languages like Haskell.

    2. Doctest Support - learn how to make your typechecked code play nicely with the doctest module.

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

  1. Introduction to Utility Classes
  2. Boolean Expressions

  3. Miscellaneous

Typeclasses

  1. Introduction to Typeclasses
  2. ImSequence - immutable sequences
  3. Mapping - the mapping interface
  4. MSequence - mutable sequences
  5. Number - numeric types
  6. String - string types

Valid XHTML 1.0 Transitional