Comments (7)
I think I've hit this. For completion's sake here's a minimal test case, and the exception thrown
data:
- zomg: lol
schema:
seq:
- map:
allowempty: True
exception:
Traceback (most recent call last):
File "kwalbug.py", line 20, in <module>
c.validate(raise_exception=True)
File "pykwalify/core.py", line 147, in validate
self._start_validate(self.source)
File "pykwalify/core.py", line 187, in _start_validate
root_rule = Rule(schema=self.schema)
File "pykwalify/rule.py", line 62, in __init__
self.init(schema, "")
File "pykwalify/rule.py", line 346, in init
func_mapping[k](v, rule, path)
File "pykwalify/rule.py", line 833, in init_mapping_value
rule.init(v, u"{}/mapping/{}".format(path, k))
File "pykwalify/rule.py", line 346, in init
func_mapping[k](v, rule, path)
File "pykwalify/rule.py", line 764, in init_sequence_value
rule.init(elem, u"{}/sequence/{}".format(path, i))
File "pykwalify/rule.py", line 346, in init
func_mapping[k](v, rule, path)
File "pykwalify/rule.py", line 833, in init_mapping_value
rule.init(v, u"{}/mapping/{}".format(path, k))
File "pykwalify/rule.py", line 278, in init
include = schema.get("include", None)
AttributeError: 'bool' object has no attribute 'get'
Version: 1.5.1 (via PyPI)
from pykwalify.
..actually I hit it with even the following, no seq involved
schema:
map:
foo: {type: str}
allowempty: True
data:
foo: asads
bar: asad
from pykwalify.
@jmtd Have you tried the schema/data with the latest commit in unstable
branch?
from pykwalify.
Hi, sorry for the delay. Yes I can confirm this with 6596293
from pykwalify.
@smalleni Your specific usecase and schema you posted is now fixed as of this commit cd012c9 and you can see your data/schema was used and it now validated properly as expected.
@smalleni @jmtd I would NOT recommend to use the map:
keyword for now becuase it is still buggy with the first example you provided @jmtd
# DO NOT USE
seq:
- map:
allowempty: True
# USE THIS INSTEAD
type: seq
sequence:
- type: map
allowempty: True
I will keep investigating why seq
& map
bugs out in that way.
from pykwalify.
@jmtd A comment after some thinking regarding the problems with seq:
and - map:
is that it is currently not possible to have allowempty: True
in the way i showed in the last comment becuase the reason that keyword/shortcut was implemented was to make it easier to write instead of having to specify type: map
& mapping: {...}
so it would be easier to write and understand what you wanted. The problem with this is that all subkeys that you specify inside the value part for the map will be considered a regular key/value pair that it should validate against data and not a keyword that it acctually is. I consider this correct behavriour from the implementation and i basically say that all extra keywords that you normally can specify for a seq
and map
keywords is not possible to have in the schema as it is right now. The only consitent way would be to do the following:
seq:
- map:
allowempty: True
mapping: {}
but by doing this it makes it really confusing compared to the normal way it is done and i would have to rewrite alot of logic just to change it into this and that is not something i will do. So the current implementaitno and the suggestion/directive i mentioned above to use USE THIS INSTEAD
section stands as the only supported way to use extra keywords for a map type.
I am closing this issue becuase there is no more issues to deal within this issue. The original issue was solved as mentioned above through commit cd012c9
from pykwalify.
I think I understand, thank you.
from pykwalify.
Related Issues (20)
- Union of schemas HOT 4
- rule.py is missing a comma in defined_keywords list
- Deprecation warning due to invalid escape sequences in Python 3.8 HOT 1
- Fails to regex match a mapping with integer keys HOT 1
- AttributeError: 'int' object has no attribute 'startswith'
- Support multiple data type HOT 1
- New release? Maintainers needed or? HOT 2
- Deprecation warning "the imp module is deprecated in favour of importlib" HOT 1
- pattern rule not working with all scalar types HOT 1
- <RuleError: error code 4
- Using fulmatch for regex matching. HOT 1
- Schema Validation Against Multiple Files HOT 1
- Outputting Scan Results in SARIF Format HOT 1
- How can I check key only? HOT 5
- anchors to inherit properties are falsely reported as Duplicate HOT 2
- ReadTheDocs does not seem to be updating
- Some error message for length violations are wrong
- issue while using "unique: true" for the sequence data type HOT 3
- Tests fail with ruamel.yaml 0.18.0
- Core Validation Fails - Multi Threading & Python 3.11 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pykwalify.