Skip to content

Fix wrong parameter name in namedtuple_dict_structure_factory#723

Merged
Tinche merged 3 commits intopython-attrs:mainfrom
bysiber:fix/namedtuple-detailed-validation-param
Mar 3, 2026
Merged

Fix wrong parameter name in namedtuple_dict_structure_factory#723
Tinche merged 3 commits intopython-attrs:mainfrom
bysiber:fix/namedtuple-detailed-validation-param

Conversation

@bysiber
Copy link
Contributor

@bysiber bysiber commented Feb 20, 2026

namedtuple_dict_structure_factory passes _cattrs_use_detailed_validation to make_dict_structure_fn_from_attrs, but the expected parameter name is _cattrs_detailed_validation (without the use_ prefix).

Since make_dict_structure_fn_from_attrs accepts **kwargs for attribute overrides, the misnamed keyword is silently swallowed as if it were an attribute override key, and _cattrs_detailed_validation falls back to its default "from_converter".

This means the detailed_validation argument to namedtuple_dict_structure_factory has no effect — the converter's default is always used regardless of what's passed.

The fix renames the keyword to match the actual parameter name.

@Tinche
Copy link
Member

Tinche commented Feb 20, 2026

Ooph, you're right, that's embarrassing.

Please add a unit test for this, and a changelog entry (you can use NEXT for the version).

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 20, 2026

Merging this PR will not alter performance

✅ 54 untouched benchmarks


Comparing bysiber:fix/namedtuple-detailed-validation-param (5fd1c7f) with main (573915b)

Open in CodSpeed

@bysiber
Copy link
Contributor Author

bysiber commented Feb 20, 2026

Added a regression test and a HISTORY.md entry in the latest push. The test creates a converter with detailed_validation=False but passes detailed_validation=True to the factory, verifying the parameter is actually forwarded correctly.

bysiber and others added 3 commits March 4, 2026 00:24
The call to make_dict_structure_fn_from_attrs passes
_cattrs_use_detailed_validation but the function expects
_cattrs_detailed_validation. Because **kwargs catches the misnamed
parameter as an attribute override, detailed_validation is silently
ignored and always falls back to the converter default.
Add a test that verifies the detailed_validation parameter passed
to namedtuple_dict_structure_factory is actually used and not
silently ignored. Also add a HISTORY.md entry for the fix.
@Tinche Tinche force-pushed the fix/namedtuple-detailed-validation-param branch from 015863a to 5fd1c7f Compare March 3, 2026 23:24
@Tinche
Copy link
Member

Tinche commented Mar 3, 2026

Thanks, I took the liberty of fixing the test and merging the changelog to nudge this along.

@Tinche Tinche merged commit 304e370 into python-attrs:main Mar 3, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants