Repository navigation
Conversation
Assisted-by: OpenAI Codex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Protocol method checks currently accept an implementation with an extra required
keyword-only parameter whenever the protocol method accepts
**kwargs. For example,meth(self, **kwargs)permitsmeth(), but an implementation declared asmeth(self, *, x, **kwargs)cannot handle that call.check_type()neverthelessaccepts both the instance and its class against the corresponding protocol.
Run the existing extra mandatory keyword-only parameter check even when the protocol
accepts arbitrary keywords. This preserves acceptance of extra parameters with defaults
and required parameters explicitly present in both signatures.
The regression tests cover
typing.Protocolandtyping_extensions.Protocol, checkingboth instances and classes. Before the fix, the four rejection cases fail; all eight
compatibility controls already pass. The incompatibility was also checked against an
actual zero-argument call and mypy 2.1.0.
Validation
coverage run -m pytest -q— 547 passed, 9 skipped, 9 xfailed.ruff check .andruff format --check .pass.configured mypy hook (which uses
--ignore-missing-imports)._decorators.py:22for theunresolved
typeshed.stdlib.typesimport. The same error occurs on an unmodifiedcheckout of base commit
123f1abc7e82bbe980c779005de858533e1786c3.Checklist
docs/versionhistory.rst.AI assistance disclosure: OpenAI Codex identified the issue through code inspection,
implemented the change, and ran the checks above. This is not a report of a production
incident experienced by the submitter.