any() inside included element causes error
See original GitHub issueIssue Description
The following schema results in an error while parsing the schema:
test_1: include('test_2')
---
test_2: any(str(), int())
Relevant part of stack trace:
File “/usr/local/lib/python2.7/site-packages/yamale/yamale.py”, line 17, in make_schema s.add_include(raw_schema) File “/usr/local/lib/python2.7/site-packages/yamale/schema/schema.py”, line 20, in add_include validators=self.validators) File “/usr/local/lib/python2.7/site-packages/yamale/schema/schema.py”, line 14, in init self._schema = self._process_schema(schema_dict, self.validators) File “/usr/local/lib/python2.7/site-packages/yamale/schema/schema.py”, line 36, in _process_schema raise SyntaxError(str(e) + ’ at node '%s' in file %s’ % (key, self.name)) SyntaxError: Invalid schema expression: ‘i’. name ‘i’ is not defined at node ‘11’ in file test_2
This is with Python 2.7 if that matters
So, if I want an element to contain one of two possible types of value, I need to do something like this instead and do some additional validation in the code that at least one of them is present:
test_1: include('test_2')
---
test_2:
test_3: str(required=False)
test_4: int(required=False)
Not sure if this is intended. Am I missing something or is there no neater way to do this? Thanks!
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
No problem, glad to help.
Okay yes I ran into a syntax error and misinterpreted it when I was trying an alternative way to write the schema. Once I fixed the syntax error it worked. Sorry to bother!