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

[BUG] LetterCase.SNAKE renders names with letters and numbers incorrectly. #555

Open
davidharcombe opened this issue Jan 29, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@davidharcombe
Copy link

Description

When rendering a field called cardsV2 or cards_v2 as LetterCase.SNAKE, the output should be

cards_v2

The current version of dataclasses_json (v0.6.7) however renders this as

cards_v_2

Code snippet that reproduces the issue

import dataclasses
import dataclasses_json


@dataclasses_json.dataclass_json(letter_case=dataclasses_json.LetterCase.SNAKE)
@dataclasses.dataclass
class Message(object):
  cardsV2: str

m = Message(cardsV2='card')
print(m.to_dict())

Output:

{'cards_v_2': 'card'}

Describe the results you expected

{'cards_v2': 'card'}

Changing my dataclasses_json in requirements.txt to

dataclasses_json==0.5.7

causes this output to be returned.

Python version you are using

Python 3.11.9

Environment description

asttokens==2.4.1
autopep8==2.0.2
bleach==6.0.0
build==0.10.0
certifi==2023.5.7
cffi==1.15.1
charset-normalizer==3.1.0
comm==0.2.0
cryptography==41.0.1
dataclasses-json>=0.5.7
debugpy==1.8.0
decorator==5.1.1
docutils==0.20.1
executing==2.0.1
idna==3.4
importlib-metadata==6.6.0
ipykernel==6.27.1
ipython==8.18.1
jaraco.classes==3.2.3
jedi==0.19.1
jeepney==0.8.0
jupyter_client==8.6.0
jupyter_core==5.5.0
keyring==23.13.1
markdown-it-py==2.2.0
marshmallow==3.19.0
marshmallow-enum==1.5.1
matplotlib-inline==0.1.6
mdurl==0.1.2
more-itertools==9.1.0
mypy-extensions==1.0.0
nest-asyncio==1.5.8
packaging==23.1
parso==0.8.3
pexpect==4.9.0
pkginfo==1.9.6
platformdirs==4.1.0
prompt-toolkit==3.0.41
psutil==5.9.6
ptyprocess==0.7.0
pure-eval==0.2.2
pycodestyle==2.10.0
pycparser==2.21
Pygments==2.15.1
pyproject_hooks==1.0.0
python-dateutil==2.8.2
pyzmq==25.1.1
readme-renderer==37.3
requests==2.31.0
requests-toolbelt==1.0.0
rfc3986==2.0.0
rich==13.4.1
SecretStorage==3.3.3
six==1.16.0
stack-data==0.6.3
stringcase==1.2.0
tornado==6.4
traitlets==5.14.0
twine==4.0.2
typing-inspect==0.9.0
typing_extensions==4.6.3
urllib3==2.0.3
wcwidth==0.2.12
webencodings==0.5.1
zipp==3.15.0

@davidharcombe davidharcombe added the bug Something isn't working label Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant