Closed wizzardx closed 7 years ago
Looks like the issue may be that Set isn't in TYPE_ALIASES: https://github.com/hwayne/enforce/blob/master/enforce/types.py#L110
On Thu, Jan 26, 2017 at 1:33 AM, wizzardx notifications@github.com wrote:
Working with 0.3.1, installed from PyPI
Example code:
import enforce
from typing import Set
@enforce.runtime_validation def test() -> Set[int]: return set([1,2,3])
test()
Error:
Traceback (most recent call last): File "/tmp/x/py35/venv/lib/python3.5/site-packages/enforce/nodes.py", line 403, in preprocess_data enforcer = data.enforcer AttributeError: 'set' object has no attribute 'enforcer'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "test.py", line 9, in test() File "/tmp/x/py35/venv/lib/python3.5/site-packages/enforce/decorators.py", line 123, in universal return enforcer.validate_outputs(result) File "/tmp/x/py35/venv/lib/python3.5/site-packages/enforce/enforcers.py", line 95, in validate_outputs if not self.validator.validate(output_data, 'return'): File "/tmp/x/py35/venv/lib/python3.5/site-packages/enforce/validator.py", line 26, in validate result = visit(validation_tree) File "/tmp/x/py35/venv/lib/python3.5/site-packages/enforce/utils.py", line 17, in visit stack.append(last.send(last_result)) File "/tmp/x/py35/venv/lib/python3.5/site-packages/enforce/nodes.py", line 45, in validate clean_data = self.preprocess_data(validator, data) File "/tmp/x/py35/venv/lib/python3.5/site-packages/enforce/nodes.py", line 405, in preprocess_data return GenericProxy(data) File "/tmp/x/py35/venv/lib/python3.5/site-packages/enforce/enforcers.py", line 129, in init raise TypeError('Only generics can be wrapped in GenericProxy') TypeError: Only generics can be wrapped in GenericProxy
Traceback (most recent call last): File "/tmp/x/py35/venv/lib/python3.5/site-packages/enforce/nodes.py", line 403, in preprocess_data enforcer = data.enforcer AttributeError: 'set' object has no attribute 'enforcer'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "test.py", line 9, in test() File "/tmp/x/py35/venv/lib/python3.5/site-packages/enforce/decorators.py", line 123, in universal return enforcer.validate_outputs(result) File "/tmp/x/py35/venv/lib/python3.5/site-packages/enforce/enforcers.py", line 95, in validate_outputs if not self.validator.validate(output_data, 'return'): File "/tmp/x/py35/venv/lib/python3.5/site-packages/enforce/validator.py", line 26, in validate result = visit(validation_tree) File "/tmp/x/py35/venv/lib/python3.5/site-packages/enforce/utils.py", line 17, in visit stack.append(last.send(last_result)) File "/tmp/x/py35/venv/lib/python3.5/site-packages/enforce/nodes.py", line 45, in validate clean_data = self.preprocess_data(validator, data) File "/tmp/x/py35/venv/lib/python3.5/site-packages/enforce/nodes.py", line 405, in preprocess_data return GenericProxy(data) File "/tmp/x/py35/venv/lib/python3.5/site-packages/enforce/enforcers.py", line 129, in init raise TypeError('Only generics can be wrapped in GenericProx
If we change Set to List then it works fine though:
import enforce
from typing import List
@enforce.runtime_validation def test() -> List[int]: return [1,2,3]
test()
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/RussBaz/enforce/issues/33, or mute the thread https://github.com/notifications/unsubscribe-auth/ACiXdLcABdPv_irPzGAcrMv55LVA4RWhks5rWEw6gaJpZM4LuXUC .
It is now fixed in the dev branch. Thanks for the reporting.
Working with 0.3.1, installed from PyPI
Example code:
Error:
If we change Set to List then it works fine though: