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

Fails if key is an int #6

Open
jacobg opened this issue Jul 29, 2020 · 1 comment
Open

Fails if key is an int #6

jacobg opened this issue Jul 29, 2020 · 1 comment

Comments

@jacobg
Copy link

jacobg commented Jul 29, 2020

A dictionary such as:

{1: "abc"}

will fail with this exception:

  File "/env/lib/python3.7/site-packages/animal_case/__init__.py", line 72, in parse_keys
    formatted[key] = parse_keys(value, types)
  File "/env/lib/python3.7/site-packages/animal_case/__init__.py", line 70, in parse_keys
    for key, value in _unpack(formatter(data)):
  File "/env/lib/python3.7/site-packages/animal_case/__init__.py", line 47, in keys_to_camel_case
    return {to_camel_case(key): value for key, value in _unpack(content)}
  File "/env/lib/python3.7/site-packages/animal_case/__init__.py", line 47, in <dictcomp>
    return {to_camel_case(key): value for key, value in _unpack(content)}
  File "/env/lib/python3.7/site-packages/animal_case/__init__.py", line 37, in to_camel_case
    content = value.split('_')
AttributeError: 'int' object has no attribute 'split'

It looks like the the to_camel_case function should return identity value if input value is not a string.

@rafa-acioly
Copy link
Owner

can you send a PR @jacobg ?

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