Skip to content

Beginner friendly error messages for missing self #152315

Description

@SurenNihalani

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)triagedThe issue has been accepted as valid by a triager.type-featureA feature request or enhancement
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions