- cattrs version: 24.1.1
- Python version: 3.12.6
- Operating System: macOS Sequoia 15.0 (24A335)
Description
Custom (un)structuring hooks appear to have incorrect typing information. cattrs v24.1.1 already seems to have fixed this for the factory variant, as described in #578 and #579, but the individual hooks still seem to be incorrect.
What I Did
The following sample code is provided by the documentation :
@converter.register_structure_hook
def my_int_hook(val: Any, _) -> int:
"""This hook will be registered for `int`s."""
return int(val)
This causes the following type warning (using Pylance in VS Code):
No overloads for "register_structure_hook" match the provided arguments
Argument types: ((val: Any, _: Unknown) -> int)