pylint-bot / test

0 stars 0 forks source link

Monkeypatch detection improperly follows method which weren't called #168

Open pylint-bot opened 9 years ago

pylint-bot commented 9 years ago

Originally reported by: Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore?)


Here's a bug that describes a problem in astroid. If we're running pylint on it, then we'll get an error that 'str' has no member 'lala', while in fact it should have said about an integer not have that member. What's happening is that astroid detects there's some monkey patching involved at some point and uses that newly patched method, disregarding any flow of the program.

#!python

class A:
    def action_type(self):
         return 42

def test():
   a = A()
   a.action_type = lambda self: 's'
   return a.action_type()

a = A()
print(a.action_type().lala)