Skip to content

Not convertible classes throw AttributeError #193

@antispam2002

Description

@antispam2002

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__

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