Skip to content

Document when on_setattr hooks run - #1663

Open
iamdatvt94 wants to merge 1 commit into
python-attrs:mainfrom
iamdatvt94:docs/on-setattr-initialization
Open

iamdatvt94 wants to merge 1 commit into
python-attrs:mainfrom
iamdatvt94:docs/on-setattr-initialization

Conversation

@iamdatvt94

Copy link
Copy Markdown

Summary

Closes #672.

Clarify why a custom on_setattr hook runs on assignment but is skipped when the generated __init__ initializes fields. The example shows the same value passed through both paths, and the guide points readers to converters and validators for initialization-time behavior.

Testing

  • tox run -e docs-doctests,docs-build on Windows with Python 3.14.
  • git diff --check.

Pull Request Checklist

  • I acknowledge this project's AI policy.
  • This PR is from a topic branch.
  • The documentation has been updated and includes a runnable example.

OpenAI Codex assisted with the documentation change and verification. I reviewed the diff before submission.

This branch has not been deployed

No deployments
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.

on_setattr doesn't apply during init

1 participant