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

Value always interpreted as string in YAML data when using key other than Str() for MapPattern #64

Open
dgg5503 opened this issue Jun 27, 2019 · 2 comments

Comments

@dgg5503
Copy link

dgg5503 commented Jun 27, 2019

After pulling strictyaml 1.0.2, I can see that the exception is no longer thrown. However, I'm running into a strange issue when viewing the parsed YAML data dictionary values. Here's an example:

>>> from strictyaml import *
>>> a = {10.25: 23, 20.33: 76}
>>> schema = MapPattern(Float(), Int())
>>> yaml = as_document(a, schema)
>>> yaml.data
OrderedDict([(10.25, '23'), (20.33, '76')])

Notice that the keys are correctly interpreted as floats, however, the values are strings instead of the expected ints.

For contrast, here is what happens if I make the keys strings:

>>> from strictyaml import *
>>> a = {'10.25': 23, '20.33': 76}
>>> schema = MapPattern(Str(), Int())
>>> yaml = as_document(a, schema)
>>> yaml.data
OrderedDict([('10.25', 23), ('20.33', 76)])

Now the values are interpreted correctly as ints.

Environment:

  • Python 3.7.3
  • strictyaml 1.0.2
  • ruamel.yaml 0.15.97
@crdoconnor
Copy link
Owner

crdoconnor commented Jun 29, 2019 via email

@smsearcy
Copy link

I'm seeing similar behavior with MapPattern(Int(), CommaSeparated(Decimal())), the values are being returned as strings. It seems this is likely the same issue?

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

3 participants