RussBaz / enforce

Python 3.5+ runtime type checking for integration testing and data validation
542 stars 21 forks source link

TypeError: 'NoneType' object is not iterable when using Optional[Tuple[str, str]] #62

Open smarie opened 6 years ago

smarie commented 6 years ago
from typing import Optional, Tuple
from enforce import runtime_validation

@runtime_validation
def foo(arg: Optional[Tuple[str, str]] = None):
    pass

foo()

Yields TypeError: 'NoneType' object is not iterable. Note that the result is the same when the argument has no default value and None is explicitly passed.

Trying to dig-in the source it seems that at some point the None value is propagated to the Tuple node, which might be ok. I will provide a pull request with a fix.