AndreaCensi/contracts

String contracts don't accept ! (not)

Opened this issue · 0 comments

Hello,

If I try using this

@contract(txt_pn='str, != ""', returns='list(str, != ""')
def load_txt2lst(txt_pn):
    # type: (str) -> List[str]
    ...

or this

@contract(txt_pn='str, != \'\'', returns='list(str, != \'\'')
def load_txt2lst(txt_pn):
    # type: (str) -> List[str]
    ...

this error is returned

...
    return parse_contract_string_actual(string)
  File "C:\Users\JMatos\Envs\solve_sudoku\lib\site-packages\contracts\main_actua
l.py", line 41, in parse_contract_string_actual
    raise ContractSyntaxError(msg, where=where)
contracts.interface.ContractSyntaxError: Expected operation with ["!"] (at char
13), (line:1, col:14)

 line  1 |list(str, != ""
                       \u2191

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "solve_sudoku.py", line 58, in <module>
    @contract(txt_pn='str, != ""', returns='list(str, != ""')
  File "C:\Users\JMatos\Envs\solve_sudoku\lib\site-packages\contracts\main.py",
line 149, in tmp_wrap
    raise e.copy()
contracts.interface.ContractSyntaxError: Expected operation with ["!"] (at char
13), (line:1, col:14)

 line  1 |list(str, != ""
                       \u2191

I am doing something wrong or is it a bug?

I'm using Python 3.5.4 32b and pycontracts 1.8.3 under Windows 7 Pro x64.

Thanks,

JM