Author chris.jerdonek
Recipients chris.jerdonek
Date 2020-05-19.07:57:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1589875049.34.0.573346435361.issue40679@roundup.psfhosted.org>
In-reply-to
Content
When calling an instance method incorrectly, you will often get a TypeError that is some variation of the following:

    Traceback (most recent call last):
      File "/.../test.py", line 6, in <module>
        a.foo(1)
    TypeError: foo() takes 1 positional argument but 2 were given

However, when multiple classes have method foo() and the type of "a" isn't immediately obvious, this often isn't enough to know what method was being called. Thus, it would be more helpful if the error message includes also the class that foo() belongs to, or alternatively the type of the object. (These can be different when subclasses are involved.)

For comparison, if you call a method that doesn't exist, you will get a message that looks like the following:

    Traceback (most recent call last):
      File "/.../test.py", line 6, in <module>
        a.bar(1)
    AttributeError: 'A' object has no attribute 'bar'

So taking from this as an example, the message in the first case could be something like--

    TypeError: foo() for 'A' object takes 1 positional argument but 2 were given
History
Date User Action Args
2020-05-19 07:57:29chris.jerdoneksetrecipients: + chris.jerdonek
2020-05-19 07:57:29chris.jerdoneksetmessageid: <1589875049.34.0.573346435361.issue40679@roundup.psfhosted.org>
2020-05-19 07:57:29chris.jerdoneklinkissue40679 messages
2020-05-19 07:57:28chris.jerdonekcreate