pylint can't deduce the type of an object
Hi all; as mentioned in a previous post, I am looking into updating my curring pylint (1.0.1) to newer pylint 1.4.0. I've got one significant problem left and I'm not sure how to resolve it: in the new pylint I'm seeing a number of errors like this: mymod.py:227: [E1101(no-member), MyMod.__str__] Instance of 'int' has no 'get_val' member The code in question is something like: self.someobj.get_val() The problem appears to be that pylint cannot tell the type of the object stored in "someobj", so it assumes "int" and gives an error. The value of self.someobj is passed in via the constructor, and so this module really _doesn't_ know the type. I checked what pylint 1.0.1 is doing and it seems to be ignoring that value altogether, so it doesn't give the above incorrect error but it also doesn't complain if, for example, I change the call to "self.someobj.getval()" (or any other non-existent method). Can I do something to get pylint to understand this type? If it cannot figure it out automatically, is there some way I can hint or annotate the type of this member so pylint will understand what it is? Is there a way to disable the "assume an int" processing and ignore unknown members, like the old pylint did, without disabling E1101 altogether? Pylint is run automatically as part of our static analysis tests so I can't upgrade until I can get the new version to run clean.
On Fri, Nov 28, 2014 at 10:57 PM, Paul Smith
Hi all; as mentioned in a previous post, I am looking into updating my curring pylint (1.0.1) to newer pylint 1.4.0.
I've got one significant problem left and I'm not sure how to resolve it: in the new pylint I'm seeing a number of errors like this:
mymod.py:227: [E1101(no-member), MyMod.__str__] Instance of 'int' has no 'get_val' member
Could you give me a small sample to reproduce this problem? If it's not an opened issue with this error, you could open one on our bug tracker, so it won't be lost in mails.
On Fri, 2014-11-28 at 23:09 +0200, Claudiu Popa wrote:
On Fri, Nov 28, 2014 at 10:57 PM, Paul Smith
wrote: Hi all; as mentioned in a previous post, I am looking into updating my curring pylint (1.0.1) to newer pylint 1.4.0.
I've got one significant problem left and I'm not sure how to resolve it: in the new pylint I'm seeing a number of errors like this:
mymod.py:227: [E1101(no-member), MyMod.__str__] Instance of 'int' has no 'get_val' member
Could you give me a small sample to reproduce this problem? If it's not an opened issue with this error, you could open one on our bug tracker, so it won't be lost in mails.
Well, it's a really complex environment but I'll see if I can come up with a simpler repro case. I just figured that this would be something that's a known issue: since python is dynamically typed it must be the case that a member can contain an object where pylint (being a static checker) cannot determine its type. Are you saying that Python should NOT be assuming the type as int here?
On Fri, 2014-11-28 at 23:09 +0200, Claudiu Popa wrote:
On Fri, Nov 28, 2014 at 10:57 PM, Paul Smith
wrote: Hi all; as mentioned in a previous post, I am looking into updating my curring pylint (1.0.1) to newer pylint 1.4.0.
I've got one significant problem left and I'm not sure how to resolve it: in the new pylint I'm seeing a number of errors like this:
mymod.py:227: [E1101(no-member), MyMod.__str__] Instance of 'int' has no 'get_val' member
Could you give me a small sample to reproduce this problem? If it's not an opened issue with this error, you could open one on our bug tracker, so it won't be lost in mails.
I constructed a small(-ish) test case and created an issue in the tracker: https://bitbucket.org/logilab/pylint/issue/400/pylint-assumes-an-incorrect-m... As mentioned there the problem seems to be that I'm creating an object on a separate thread, asynchronously, based on some content I'm reading over a network socket and then when I try to use the object on the main thread pylint isn't able to deduce the type.
participants (2)
-
Claudiu Popa
-
Paul Smith