-
Notifications
You must be signed in to change notification settings - Fork 220
fix False negative on extra arguments to paramspec callable #1687 #1760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes issue #1687 by ensuring that ParamSpec-based protocol checks can detect extra keyword arguments when checking class constructors. The fix synthesizes a __call__ attribute for class objects that exposes the actual constructor signature (derived from __new__/__init__) instead of falling back to the permissive type.__call__.
Key Changes:
- Synthesizes constructor-backed
__call__attribute for class objects during attribute lookup - Applies to both the magic dunder fast path and regular class object attribute lookup
- Enables proper signature validation for ParamSpec protocols like middleware factories
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pyrefly/lib/test/paramspec.rs | Adds regression test for FastAPI-style middleware pattern to ensure extra kwargs are detected |
| pyrefly/lib/alt/attr.rs | Implements synthetic __call__ attribute synthesis using constructor_to_callable for class objects in both magic dunder and regular attribute lookup paths |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Where's the location that looks up |
|
@yangdanny97 has imported this pull request. If you are a Meta employee, you can view this in D88641669. |
ndmitchell
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review automatically exported from Phabricator review in Meta.
|
@yangdanny97 merged this pull request in cdab03e. |
|
Thank you! |
Summary
Fixes #1687
Now synthesize a constructor-backed
__call__attribute for class objects (including the magic-dunder fast path), so protocol/ParamSpec checks see the actual constructor signature instead of the permissivetype.__call__, letting kwargs mismatches surface.Test Plan
Adds a regression test covering the FastAPI-style middleware helper to lock in the new error behavior.