We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d7f3c34 commit 81bbf6bCopy full SHA for 81bbf6b
src/attr/_make.py
@@ -2325,10 +2325,15 @@ def _attrs_to_init_script(
2325
" "
2326
+ f"val = {init_factory_name}({maybe_self})"
2327
)
2328
- lines.append(
2329
- " "
2330
- + f"{validator_name}(self, a, val)"
2331
- )
+ if a.validator is not None:
+ val_name = "__attr_validator_" + a.name
+ attr_name_ref = "__attr_" + a.name
+ lines.append(
2332
+ " "
2333
+ + f"{val_name}(self, {attr_name_ref}, val)"
2334
+ )
2335
+ names_for_globals[val_name] = a.validator
2336
+ names_for_globals[attr_name_ref] = a
2337
lines.append(
2338
2339
+ fmt_setter(
0 commit comments