Skip to content

Reject assigning a string to an attribute index - #34

Merged
awolverp merged 1 commit into
awolverp:masterfrom
andersk:setitem-string
Oct 8, 2026
Merged

awolverp merged 1 commit into
awolverp:masterfrom
andersk:setitem-string

Conversation

@andersk

@andersk andersk commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

AttrsList.__setitem__ with an integer index treated a string value as a (key, value) pair, so attrs[0] = "confirm" renamed the first attribute to "c" and set its value to "o".

Raise TypeError instead, and describe the accepted combinations with overloads, so that type checkers report it too.

AttrsList.__setitem__ with an integer index treated a string value as
a (key, value) pair, so attrs[0] = "confirm" renamed the first
attribute to "c" and set its value to "o".

Raise TypeError instead, and describe the accepted combinations with
overloads, so that type checkers report it too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
@awolverp
awolverp merged commit 12ce440 into awolverp:master Oct 8, 2026
12 checks passed
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.

2 participants