Skip to content

Expand single-string slots as one attribute - #79

Open
dajiaohuang wants to merge 1 commit into
alexmojaki:mainfrom
dajiaohuang:fix/string-slots-expansion
Open

dajiaohuang wants to merge 1 commit into
alexmojaki:mainfrom
dajiaohuang:fix/string-slots-expansion

Conversation

@dajiaohuang

Copy link
Copy Markdown

Attrs documents expansion of __slots__, but a valid single-string declaration such as __slots__ = 'value' is iterated character by character. Consequently Attrs('obj') omits obj.value even when it is populated.

Normalize string slots to a one-item tuple before chaining with dictionary attributes. Add parameterized tests for string, tuple and list declarations, including attribute exclusion.

Validation on Python 3.13: original string-slot case fails (tuple/list pass); fixed regression: 3 passed. Full pytest: 53 passed, 1 failed. The existing test_sample[color] snapshot differs with the installed Pygments 2.21.0; the same failure reproduces on unmodified HEAD (color subset: 1 failed, 1 passed). git diff --check passes. Tests use synthetic objects/programs in an isolated task environment; no other Python version or CI result is claimed.

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.

1 participant