Skip to content

Abstractset reflected dunders - #16609

Open
tqa236 wants to merge 4 commits into
python:mainfrom
tqa236:abstractset-reflected-dunders
Open

tqa236 wants to merge 4 commits into
python:mainfrom
tqa236:abstractset-reflected-dunders

Conversation

@tqa236

@tqa236 tqa236 commented Oct 24, 2026

Copy link
Copy Markdown

Closes #15532

#16502 already did most of the heavy lifting work by giving set and frozenset their own correct reflected operators, this PR only needs to add generic fallback methods of the missing operators to AbstractSet and specify all possible return types in SetProxy, depending on the other operand.

The ignore comment for the boltons stub is needed because it returns the type of other there, which can be a list.

https://github.com/mahmoud/boltons/blob/4332b35a278d694f30c99881faa61cde695c7a96/boltons/setutils.py#L354-L356

AI disclosure: I use Claude Opus 5.5 to help solve this issue.

tqa236 and others added 4 commits October 24, 2026 10:25
Closes python#15532

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The proxy forwards to a real `set`, so a `frozenset` operand yields a
`frozenset` and non-set operands yield `NotImplemented`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It returns `type(other)(...)`, which need not be a set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

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.

Missing reflected dunder methods from AbstractSet

1 participant