Thursday, September 29, 2005

New version of typecheck module

I've released version 0.1.4 of my typechecking module for python. This version contains a fix that allows you to use doctest tests within typechecked functions.

This doesn't work out of the box since the doctest module looks for tests by recursing through a set of objects and looking for docstrings. If it finds a function, it checks that the functions func_globals object is the same object as the function's module's __dict__ property. This is not true of any decorated function where the decorator is defined outside the module the function is defined in.

Anyway, the new typecheck.doctest module allows you to bypass the check that doctest usually uses and replaces it with a much more liberal one that just verifies that a function's __module__ property is the same as the name of the module in which the function is defined.

No comments: