My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
AnnotationTools  

Featured, Phase-Deploy
Updated Feb 4, 2010 by ferenczi...@gmail.com

Annotation Tools

Introduction

The anntools package provides various tools to take advantage of Python 3.0's new function annotation feature.

See also: PEP #3107 - Function annotations

Examples

You can find examples for various features at the following pages:

You can also find examples in the unit tests, but they are somewhat obscure due to compatibility reasons for all supported Python version.

Tutorials

You can find quick tutorials for various features at the following pages:

  • ValidatorTutorial
  • ConverterTutorial
  • TypeCheckerTutorial

Documentation

Complete, generated API documentation

Features

Annotators for function arguments and return values

  • ValidatorAnnotators - Validators can be used to check parameters and return value.
  • ConverterAnnotators - Converters can be used to convert / marshall values when passed to functions or returned from them.
  • TypeCheckDecorator - The type check decorator can be used to quickly check the data type without cooperation.
  • CustomAnnotators - You can add your custom annotator easily.

CooperationSchemes enabling the use of multiple tools at the same time on the same subject

  • TupleCooperation (default) - Cooperation model that stores shared items in a tuple.
  • ListCooperation - Cooperation model that stores shared items in a list.
  • DictCooperation - Cooperation model that stores shared items in a dictionary. Each tool must have a unique key to access its own items.
  • NoCooperation - Cooperation model that raises and exception when multiple tools try to set the same item.
  • CustomCooperation - You can add your own cooperation model easily.

Support for Python <3.0 by passing annotations as keyword arguments of decorators instead of using the new 3.0 syntax.

Requirements

Python 2.4 or newer, Python 2.6b1 and 3.0b1 are supported

Installation

Installation on Linux

Installation on Windows

Unit testing

You need the source distribution, since it contains the unit tests in the tests subdirectory. Run test.bat or test.sh depending on your platform. You can remove the calls for the Python versions not installed to your machine. You can run the unit test scripts from the tests subdirectory manually. Some Python IDEs support adding unit tests using wildcards, which could be useful for developers.


Sign in to add a comment
Powered by Google Project Hosting