You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Beginner friendly error messages for missing self #152315
I really like the idea. However, I think it is important to keep in mind that self is only a naming convention, as the first argument represents the instance. Hence, I think we could say "Did you forget the instance parameter (e.g., self), in the function definition?"
Otherwise, it could be confusing to users (e.g., only adding the self parameter, adding it not on the first position, etc)
Activity
lul-cas commentedon Jun 26, 2026
lul-cas commentedon Jun 26, 2026
edvilme commentedon Jun 26, 2026
I really like the idea. However, I think it is important to keep in mind that
selfis only a naming convention, as the first argument represents the instance. Hence, I think we could say "Did you forget the instance parameter (e.g., self), in the function definition?"Otherwise, it could be confusing to users (e.g., only adding the self parameter, adding it not on the first position, etc)
SurenNihalani commentedon Jun 26, 2026
lul-cas commentedon Jun 26, 2026
edvilme commentedon Jun 26, 2026
terryjreedy commentedon Jun 26, 2026
There was sufficient agreement on the discussion to do this. PyPy already adds a hint in a specific circumstance.
wookie184 commentedon Jul 2, 2026
This was previously discussed + implemented in #87144 + #24272, but rejected.
pythongh-152315: Refine missing self TypeError hint
pythongh-152315: Use descriptive TypeError test fixtures
pythongh-152315: Document missing self heuristic
pythongh-152315: Cover metaclass descriptors
20 remaining items
pythongh-152315: Clarify missing self heuristic
pythongh-152315: Remove redundant argcount check
pythongh-152315: Compute missing self hint only when error is raised
pythongh-152315: Pin first argument for missing self hint
pythongh-152315: Initialize first_argument before the fail_pre_positi…
pythongh-152315: Drop comment
pythongh-152315: Fix misleading test names and drop duplicate tests
pythongh-152315: Fix comment style and typos in suggest_missing_self
pythongh-152315: Rename TypeError message helper to match assertIn se…
pythongh-152315: Add tests for no-hint branches in suggest_missing_self
pythongh-152315: Make cls-named-parameter test exercise the name check
pythongh-152315: Assert hint absence in no-suggest tests
pythongh-152315: Strip trailing whitespace in test_call
gh-152315: Add a suggestion for missing `self` parameters (GH-152326)