[issue42978] Improve error message when "self" is missing from the method definition

2021-01-20 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- resolution: -> rejected stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue42978] Improve error message when "self" is missing from the method definition

2021-01-20 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: Thanks, everyone for your valuable comments and for explaining your concerns! I will close the PR as it seems that there is no clear consensus that will be a win after balancing the problems. -- ___ Python

[issue42978] Improve error message when "self" is missing from the method definition

2021-01-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: -0 for this PR. It would cause more problems than it solves, and traditionally we leave this sort of problem for linters and type checkers. Also, this kind of error surfaces readily with even minimal testing. So, I don't think this PR is worth it. Tha

[issue42978] Improve error message when "self" is missing from the method definition

2021-01-20 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: Of course, being said all this, if the general consensus is that is not worth the trouble, I am happy to retract the PR :) -- ___ Python tracker

[issue42978] Improve error message when "self" is missing from the method definition

2021-01-20 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > Guido already listed them. Library functions, static and class methods, PR 24272 will work on all those cases. > and names like slf and _self (used either in local classes and wrapper > functions to avoid conflict with the self parameter of the ou

[issue42978] Improve error message when "self" is missing from the method definition

2021-01-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > Could you list some cases where this will give the wrong advice? Guido already listed them. Library functions, static and class methods, and names like slf and _self (used either in local classes and wrapper functions to avoid conflict with the self para

[issue42978] Improve error message when "self" is missing from the method definition

2021-01-20 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > Do you also exclude class and static methods? Yup, there is a test in the PR for that IIRC >I still worry that this might confuse users when a library for some reason >uses a different name than 'self'. That's a good point but I think it should be

[issue42978] Improve error message when "self" is missing from the method definition

2021-01-20 Thread Guido van Rossum
Guido van Rossum added the comment: > I use the same heuristic as Pypy: the callable is a bound method, the first > name in the definition is not named "self" and it was called with n+1 > positional arguments. Okay, that makes sense, you could have said so in the bug or PR description. :-)

[issue42978] Improve error message when "self" is missing from the method definition

2021-01-20 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > Seems that that guess will be wrong in most cases. Maybe I am missing something. Could you list some cases where this will give the wrong advice? -- ___ Python tracker

[issue42978] Improve error message when "self" is missing from the method definition

2021-01-20 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > I don't think this makes sense. How do you know there's a missing 'self'? > Surely it's just as likely that there is indeed an extra argument. Especially > if A.foo is defined by a library (stdib or 3rd party). I use the same heuristic as Pypy: the

[issue42978] Improve error message when "self" is missing from the method definition

2021-01-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Concur with Guido. Seems that that guess will be wrong in most cases. -- nosy: +serhiy.storchaka ___ Python tracker ___ ___

[issue42978] Improve error message when "self" is missing from the method definition

2021-01-20 Thread Guido van Rossum
Guido van Rossum added the comment: I don't think this makes sense. How do you know there's a missing 'self'? Surely it's just as likely that there is indeed an extra argument. Especially if A.foo is defined by a library (stdib or 3rd party). -- nosy: +gvanrossum ___

[issue42978] Improve error message when "self" is missing from the method definition

2021-01-20 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- keywords: +patch pull_requests: +23095 stage: -> patch review pull_request: https://github.com/python/cpython/pull/24272 ___ Python tracker __

[issue42978] Improve error message when "self" is missing from the method definition

2021-01-20 Thread Pablo Galindo Salgado
New submission from Pablo Galindo Salgado : We currently say: Traceback (most recent call last): File "/Users/pgalindo3/github/python/master/lel.py", line 5, in A().foo(1,2) TypeError: foo() takes 2 positional arguments but 3 were given but we should say: Traceback (most recent call las