Sun 25 Jun 2006
typecheck has kinda been on the back burner for…oh…the last few months, let’s say. In my defense, I’ve been a bit busy, primarily with the “travelling around Europe” thing. However, I’ve also been hard at work at a PEP to add function annotations to Python 3.0 — a project I hope to have more news on shortly.
Today, however, typecheck took a good-size surge forward. The main thrust of the 40+ commits were to bring typecheck more into line with the style of function annotations that Python 3.0 will have. To this end:
-
In past releases of
typecheck, it’s been required that every parameter have a type annotation. In 0.4, this will change; type annotations, now done exclusively through keyword arguments, will be completely optional. To wit, withtypecheck< 0.4, this:@accepts(Number, Number) def foo(a, b): ...becomes
@accepts(a=Number, b=Number) def foo(a, b): ... -
Since types are now optional, there’s no need for things like
Self(), which will go away -
The dual spellings of types for
*vargsand**kwargsare going bye-bye. Whereas intypecheck< 0.4 these were equivalent@accepts(vargs=Number) def sum(*vargs): .... @accepts(vargs=[Number]) def sum(*vargs): ....In
typecheck0.4, the latter signature will expect that each argument tosumis a list of Numbers.
In addition, the Xor(), Not() and Any() annotation classes are going away; they’re being spun off into a separate type_algebra package that will be shipped in typecheck’s contrib directory. More on that later, too.