Skip to content

Spurious Type failure on register_structure_hook_factory? #578

@stephenprater

Description

@stephenprater
  • cattrs version - 24.0.1
  • Python version - 3.12.4
  • Operating System - OSX 14.6.1

Description

When attempting to use register_structure_hook_factory for my custom structure hook, I get a type error that the decorator expects 1 more positional argument:

@my_converter.register_structure_hook_factory(lambda r: r is MyClass)
def register_review_category_struct(cls: Type[MyClass], conv: cattrs.Converter) -> StructureHook:
    return cattrs.gen.make_dict_structure_fn(
        cls,
        conv,
    )
Screenshot 2024-09-04 at 9 19 21 AM

Using pyright 1.1.379.

The structure factory works in that it creates the correct methods and that my_converter.structure(a_dict, MyClass) - does what it's supposed to but I'm wondering if I'm missing something or if the type error is spurious.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions