pycontracts supports runtime type and bound checking on Python 2 & 3

There is a global toggle:
https://andreacensi.github.io/contracts/overhead.html#overhead

Unfortunately, the type specifiers precede and are different (e.g lowercase) from those used for static analysis in mypy.

There are orobably additional differences?

On Jul 8, 2016 11:04 AM, "David Mertz" <mertz@gnosis.cx> wrote:
I provided a decorator recipe to do just what Chris Angelico describes a year or two before PEP 484 described static typechecking.  I think what I do is a consistent subset of PEP 484 still, modulo the difference between runtime and static.

See: http://code.activestate.com/recipes/578528-type-checking-using-python-3x-annotations/

It would be a lot more work to do everything the typing.py module and PEP 484 describes (algebraic typing, basically), but it's all just code that is compatible back to Python 3.0.

On Fri, Jul 8, 2016 at 3:34 AM, Paul Moore <p.f.moore@gmail.com> wrote:
On 8 July 2016 at 10:35, Chris Angelico <rosuav@gmail.com> wrote:
>> Anyway, I just throw an idea to here. Greet to all of you for bring
>> Python to me.
>
> Keep on throwing ideas this way! Ideas are great. Well-thought-out
> ideas make for interesting discussions, even if they don't get
> implemented. Often the answer ends up being "here's a way to do this
> with the current version", but it doesn't carry with it a tag of "and
> you're an idiot for even suggesting it". We like ideas here -
> otherwise we wouldn't subscribe to this list :)

Agreed! I'd have never even thought of Chris' decorator approach
before this discussion occurred, so thanks for raising the subject. I
may never use it, but knowing how to do something like this is great.

Paul
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/



--
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons.  Intellectual property is
to the 21st century what the slave trade was to the 16th.

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/