[Python-ideas] Add an option that allow check Type Hints in runtime

Wes Turner wes.turner at gmail.com
Fri Jul 8 12:12:08 EDT 2016


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 at 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 at gmail.com> wrote:
>
>> On 8 July 2016 at 10:35, Chris Angelico <rosuav at 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 at 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 at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160708/665ed6e3/attachment.html>


More information about the Python-ideas mailing list