Skip to content

[BUG] Functions in LetterCase aren't members of the enum #544

@benberryallwood

Description

@benberryallwood

Description

The attributes in the LetterCase enum are functions, so they're being registered as methods rather than enum members.

Mypy doesn't recognise this as an issue, but Pyright shows errors when trying to do, e.g., @dataclass_json(letter_case=LetterCase.CAMEL):

Argument of type "(string: Unknown) -> (Unknown | Literal[''])" cannot be assigned to parameter "letter_case" of type "LetterCase | None" in function "dataclass_json"   Type "(string: Unknown) -> (Unknown | Literal[''])" is not assignable to type "LetterCase | None"     "function" is not assignable to "LetterCase"     "function" is not assignable to "None"

Code snippet that reproduces the issue

from dataclasses_json import LetterCase

assert isinstance(LetterCase.CAMEL, LetterCase)

Describe the results you expected

LetterCase.CAMEL should be an instance of LetterCase, so this assertion should pass

Python version you are using

Python 3.10.13

Environment description

attrs==23.1.0
black==22.12.0
certifi==2023.7.22
charset-normalizer==3.2.0
click==8.1.7
coverage==7.2.7
docstring-parser==0.15
exceptiongroup==1.1.3
falcon==2.0.0
flake8==5.0.4
ghp-import==2.1.0
gitdb==4.0.10
GitPython==3.1.32
hug==2.6.1
hypothesis==6.79.4
idna==3.4
importlib-metadata==4.2.0
iniconfig==2.0.0
Jinja2==3.1.2
livereload==2.6.3
Mako==1.2.4
Markdown==3.3.4
MarkupSafe==2.1.3
marshmallow==3.19.0
mccabe==0.7.0
mergedeep==1.3.4
mkdocs==1.2.4
mkdocs-material==7.3.0
mkdocs-material-extensions==1.1.1
mypy==1.4.1
mypy-extensions==1.0.0
packaging==23.1
pathspec==0.11.2
pdocs==1.2.0
platformdirs==3.10.0
pluggy==1.2.0
portray==1.7.0
pycodestyle==2.9.1
pyflakes==2.5.0
Pygments==2.16.1
pymdown-extensions==7.1
pytest==7.4.0
pytest-cov==2.12.1
python-dateutil==2.8.2
PyYAML==6.0.1
pyyaml_env_tag==0.1
requests==2.31.0
simplejson==3.19.1
six==1.16.0
smmap==5.0.0
sortedcontainers==2.4.0
toml==0.10.2
tomli==2.0.1
tornado==6.2
typing-inspect==0.9.0
typing_extensions==4.7.1
urllib3==2.0.4
watchdog==3.0.0
yaspin==0.15.0
zipp==3.15.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions