-
Notifications
You must be signed in to change notification settings - Fork 61
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
Comments
Yep, that looks like a bug. Thanks!
…On Thu, 20 Jun 2019, 06:59 Douglas, ***@***.***> wrote:
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
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#61?email_source=notifications&email_token=ABOJKNOHHLOBTVI2QO4LQXLP3K24DA5CNFSM4HZN7FE2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G2QQSGQ>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABOJKNMDW4NLPPTV5PO5VFTP3K24DANCNFSM4HZN7FEQ>
.
|
crdoconnor
added a commit
that referenced
this issue
Jun 26, 2019
…ing (float) as a key - hat tip @dgg5503.
@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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Attempting to retrieve the
OrderedDict
form of data from a YAML object results in an exception if the schema contains aMapPattern
with a key other thanStr()
:Changing the key from
Float()
toStr()
and then converting separately would be a less than ideal workaround.Environment:
The text was updated successfully, but these errors were encountered: