Skip to content
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

Exception when accessing parsed YAML data using key other than Str() for MapPattern #61

Closed
dgg5503 opened this issue Jun 19, 2019 · 2 comments

Comments

@dgg5503
Copy link

dgg5503 commented Jun 19, 2019

Attempting to retrieve the OrderedDict form of data from a YAML object results in an exception if the schema contains a MapPattern with a key other than Str():

Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from strictyaml import *
>>> my_dict = {10.25: 23, 20.33: 76}
>>> schema = MapPattern(Float(), Int())
>>> yaml = as_document(my_dict, schema)
>>> yaml.as_yaml()
'10.25: 23\n20.33: 76\n'
>>> yaml.data
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\venv\lib\site-packages\strictyaml\representation.py", line 114, in data
    mapping[key.data] = value.data
AttributeError: 'str' object has no attribute 'data'

Changing the key from Float() to Str() and then converting separately would be a less than ideal workaround.

Environment:

  • Python 3.7.3
  • strictyaml 1.0.1
  • ruamel.yaml 0.15.96
@crdoconnor
Copy link
Owner

crdoconnor commented Jun 20, 2019 via email

crdoconnor added a commit that referenced this issue Jun 26, 2019
@dgg5503
Copy link
Author

dgg5503 commented Jun 27, 2019

@crdoconnor thanks for swiftly fixing the issue! I'm now seeing a new issue: #64.

I will close this one since the data can be parsed without any exceptions.

@dgg5503 dgg5503 closed this as completed Jun 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants