AndreaCensi / contracts

PyContracts is a Python package that allows to declare constraints on function parameters and return values. Contracts can be specified using Python3 annotations, or inside a docstring. PyContracts supports a basic type system, variables binding, arithmetic constraints, and has several specialized contracts and an extension API.
http://andreacensi.github.io/contracts/
Other
399 stars 61 forks source link

Unicode strings for contract names #40

Closed brokenseal closed 9 years ago

brokenseal commented 9 years ago

Hi, first of all, thanks for your awesome library! Second, I added your library in a project of mine where I include unicode_literals (from future ) in all the modules, that is causing me some issues with your library because the contract decorator expects a lot of things but not a unicode object.

I was wondering if you could check on contracts/main.py:337 if the spec is an instance of basestring instead of str so that unicode will also match.

Thanks!

AndreaCensi commented 9 years ago

I fixed the checks that I could find so this might be partially fixed. The changes are in master and with the latest release 1.7.4. Let me know if I forgot some other check.

brokenseal commented 9 years ago

Yup, thank you :+1: