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
398 stars 62 forks source link

how to contract against types in packages or namespaces? #43

Open kotoroshinoto opened 8 years ago

kotoroshinoto commented 8 years ago

@contract(handle='io.TextIOBase', returns='None') def read_file_handle(self, handle: io.TextIOBase) -> 'None':

this errors: contracts.interface.ContractSyntaxError: Unknown identifier 'io'. Did you mean 'np_zeroshape_array'? (at char 0), (line:1, col:1)

AndreaCensi commented 8 years ago

This is not supported yet.

On Tue, Oct 6, 2015 at 4:21 PM, kotoroshinoto notifications@github.com wrote:

@contract https://github.com/contract(handle='io.TextIOBase', returns='None') def read_file_handle(self, handle: io.TextIOBase) -> 'None':

this errors: contracts.interface.ContractSyntaxError: Unknown identifier 'io'. Did you mean 'np_zeroshape_array'? (at char 0), (line:1, col:1)

— Reply to this email directly or view it on GitHub https://github.com/AndreaCensi/contracts/issues/43.

ramalhoruben commented 7 years ago

Same problem here, is there any known workaround ?! Thanks