Skip to content

AttributeError during fetching __orig_bases__ on non-generic protocol implementation. #374

@nekitdev

Description

@nekitdev
  • cattrs version: 23.1.2
  • python version: 3.11.3
  • operating system: windows 11

Description

I wanted to register an unstructure hook for an Entity type derived from the non-generic Binary protocol.

What I Did

CONVERTER.register_unstructure_hook(
    Entity, make_dict_unstructure_fn(Entity, CONVERTER, client_unchecked=override(omit=True))
)

Which caused an error:

  File ".../cattrs/gen/__init__.py", line 82, in make_dict_unstructure_fn
    mapping = generate_mapping(cl, mapping)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../cattrs/gen/_generics.py", line 32, in generate_mapping
    orig_bases = cl.__orig_bases__
                 ^^^^^^^^^^^^^^^^^
AttributeError: type object 'Entity' has no attribute '__orig_bases__'

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions