Open pylint-bot opened 9 years ago
Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):
A simpler test which triggers the problem:
#!python
class TestListener(object):
def __init__(self):
self._latest = None
def wait(self, timeout):
result = self._latest
self._latest = None
return result
def peer_joined(self, peer):
self._latest = peer
listener = TestListener()
broker = listener.wait(3).get_domain()
The problem is not related to multithreading or sockets or whatever, it's just that Astroid, Pylint's inference engine, passes contexts in wrong way. For instance, in peer_join Astroid will think that peer is actually 3 which will make it think that wait
returns None and/or 3, then yielding the no-member warning.
Originally reported by: Paul Smith (BitBucket: pdsmith, GitHub: @pdsmith?)
I'm updating from an old pylint 1.1.0 to pylint 1.4.0 (I'm using Python 2.7.8). In the new version I'm getting an incorrect error like this:
E:123,10: Instance of 'int' has no 'get_domain' member (no-member)
even though the instance does have a method of that name. It seems that the way my code assigns a value to this member (in a separate thread, asynchronously based on some XML content sent over a socket) can't be tracked by pylint and where the previous version would ignore the issue the new one appears to assume a type of 'int' and fails. Even if I invoked a garbage method the old pylint never complained: the new pylint complains for all methods, real or garbage.
I've attached a repro case.