Skip to content

Handle attrs.asdict sets of instances#1572

Open
lin-hongkuan wants to merge 1 commit into
python-attrs:mainfrom
lin-hongkuan:codex/asdict-set-of-instances
Open

Handle attrs.asdict sets of instances#1572
lin-hongkuan wants to merge 1 commit into
python-attrs:mainfrom
lin-hongkuan:codex/asdict-set-of-instances

Conversation

@lin-hongkuan

Copy link
Copy Markdown

Fixes #1180.

Summary

  • allow recursive attrs.asdict() to finish when retained set-like collections contain attrs instances that become dictionaries
  • fall back to a list only for set and frozenset when the converted values are unhashable
  • cover both set and frozenset regressions in the next-gen attrs.asdict() tests

Tests

  • uv run --python C:\Users\lin20\AppData\Local\Programs\Python\Python312\python.exe --with-editable . --group tests pytest tests\test_next_gen.py::TestAsDict -q
  • uv run --python C:\Users\lin20\AppData\Local\Programs\Python\Python312\python.exe --with-editable . --group tests pytest tests\test_next_gen.py -q
  • uv run --python C:\Users\lin20\AppData\Local\Programs\Python\Python312\python.exe --with-editable . --group tests pytest tests\test_funcs.py::TestAsDict -q
  • uv run --python C:\Users\lin20\AppData\Local\Programs\Python\Python312\python.exe --with-editable . --group dev ruff check src\attr\_funcs.py tests\test_next_gen.py
  • uv run --python C:\Users\lin20\AppData\Local\Programs\Python\Python312\python.exe --with-editable . --group dev ruff format --check src\attr\_funcs.py tests\test_next_gen.py
  • git diff --check

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.

attr.asdict -> attrs.asdict regression for sets of instances

1 participant