Skip to content

DOC clarify attrs.define generated class example - #1622

Open
zihjiang wants to merge 1 commit into
python-attrs:mainfrom
zihjiang:docs/fix-why-example-1472
Open

DOC clarify attrs.define generated class example#1622
zihjiang wants to merge 1 commit into
python-attrs:mainfrom
zihjiang:docs/fix-why-example-1472

Conversation

@zihjiang

@zihjiang zihjiang commented Sep 11, 2026

Copy link
Copy Markdown

Problem

The @attrs.define example in the “hand-written classes” section shows a __hash__ method even though the decorator's defaults produce unhashable classes. It also omits the default slots generated by attrs.define, which makes the comparison misleading.

Changes

  • Add the generated __slots__ to the equivalent hand-written example.
  • Remove the generated __hash__ method from the example.
  • State the relevant @attrs.define defaults explicitly.

Testing

  • uv run tox run -e docs-build
  • uv run prek run --files docs/why.md
  • git diff --check

Related issue

Closes #1472

AI disclosure

AI assistance was used to locate and draft this small documentation change. I reviewed the issue, contribution policy, resulting diff, and validation output, and I understand and take responsibility for the submitted change.

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.

Add utility to print source of attrs class.

1 participant