python / python/cpython

Beginner friendly error messages for missing self

Open
#152,315 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

interpreter-core triaged type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Feature or enhancement

Proposal:
>>> class A:
...     def lol(a):
...         print(a)
...
>>> A().lol(1)
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    A().lol(1)
    ~~~~~~~^^^
TypeError: A.lol() takes 1 positional argument but 2 were given

I'd like to request a better experience for this use case.

Has this already been discussed elsewhere?

https://discuss.python.org/t/beginner-friendly-error-messages-for-missing-self-typeerror-a-lol-takes-1-positional-argument-but-2-were-given/107414

Links to previous discussion of this feature:

No response

Linked PRs
  • gh-152326

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the A().lol(1) example in the issue, then read the linked discussion and PR gh-152326 to understand the proposed direction. Done means the project has an agreed beginner-friendly treatment for this missing-self TypeError and the linked work is resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
developer-experience
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.