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

Not convertible classes throw AttributeError #193

Open
antispam2002 opened this issue May 2, 2022 · 0 comments
Open

Not convertible classes throw AttributeError #193

antispam2002 opened this issue May 2, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@antispam2002
Copy link

antispam2002 commented May 2, 2022

Since 8.5.6+, an attempt to call class_schema on a class that cannot be converted by marschmallow_dataclass throws AttributeError. Previously it was a TypeError which is somehow meaningful because the type is not convertible.
Example:

from marshmallow_dataclass import class_schema
from typing import Callable

class NonDataClass:
    f: Callable[[str, str], int]

class_schema(NonDataClass)

Expected (was in versions up to 8.5.5):
throws TypeError as

TypeError: typing.Callable[[str, str], int] is not a dataclass and cannot be turned into one.

Actual (version 8.5.6, 8.5.7, 8.5.8):

...
  File "venv/lib/python3.9/site-packages/marshmallow_dataclass/__init__.py", line 367, in _internal_class_schema
    _RECURSION_GUARD.seen_classes[clazz] = clazz.__name__
  File ".pyenv/versions/3.9.9/lib/python3.9/typing.py", line 710, in __getattr__
    raise AttributeError(attr)
AttributeError: __name__
@antispam2002 antispam2002 changed the title Incontrovertible classes throw AttributeError Not convertible classes throw AttributeError May 2, 2022
@lovasoa lovasoa added the bug Something isn't working label May 2, 2022
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

2 participants