-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set[] return type has errors #33
Comments
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 ***@***.***> 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
<#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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Working with 0.3.1, installed from PyPI
Example code:
Error:
If we change Set to List then it works fine though:
The text was updated successfully, but these errors were encountered: