-
-
Notifications
You must be signed in to change notification settings - Fork 34.8k
gh-152315: Add a suggestion for self #152326
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
Open
SurenNihalani
wants to merge
18
commits into
python:main
Choose a base branch
from
SurenNihalani:missing_self
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+186
−19
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
6fb818b
Suggest missing 'self' when a method is called with too many position…
SurenNihalani d43c008
Respond to comments about giving typeerror without hint and changing …
SurenNihalani 8cec83f
Add test for happy path
SurenNihalani 6446c5a
Missing semicolon
SurenNihalani eda21d6
Fix tests
SurenNihalani b8bf56e
Be simpler
SurenNihalani 592f419
Change methodology
SurenNihalani ef5da0f
Add misc
SurenNihalani 715b6fa
Dont give hints when first arg is already named self
SurenNihalani 5ad3b07
gh-152315: Refine missing self TypeError hint
SurenNihalani 3299fe9
gh-152315: Use descriptive TypeError test fixtures
SurenNihalani ae7720a
gh-152315: Document missing self heuristic
SurenNihalani 586c65b
gh-152315: Cover metaclass descriptors
SurenNihalani 9b1d491
gh-152315: Rename metaclass test fixture
SurenNihalani 95039a6
gh-152315: Align missing self docs wording
SurenNihalani 32fb5e8
gh-152315: Add agent guidance
SurenNihalani f4669fa
gh-152315: Remove agent guidance
SurenNihalani 2b80cb2
gh-152315: Clarify missing self heuristic
SurenNihalani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
3 changes: 3 additions & 0 deletions
3
Misc/NEWS.d/next/Core_and_Builtins/2026-06-26-20-37-22.gh-issue-152315.iVS7u5.rst
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| :exc:`TypeError` messages for some instance methods called with too many | ||
| positional arguments now suggest checking whether the method definition is | ||
| missing the ``self`` parameter. |
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
Oops, something went wrong.
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.
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.
The heuristic of matching tp_name against the class segment in qualname is solid. A negative test for a @classmethod missing cls would be useful, it probably shouldnt trigger the hint, and that would document the expected behavior.
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.
I've switched it to checking function name matching the self dictionary. Please take a fresh look at the PR and lmk if it suffices.