Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Incorrectly determines mock objects are of type dict when mocking a module #697
Originally reported by: Anonymous
Give these two files:
The code works fine:
But pylint incorrectly determines that self.os_mock is of type dict:
The test_mock_is_mock test above shows that this is explicitly not the case.
This is using python 2.7.6
I don't think there's anyway for pylint to figure out what mock is doing behind the scene in a sane way. These kind of libraries which overuses dynamic features of the language aren't well suited for a static analysis understanding.
But this might be solvable with an astroid brain plugin.
Closing this. I think it is not worth investing effort into something relying heavily on patching things and magic, as mock is doing it. if anyone wants to spend some effort fixing this, you might have a look at how astroid brain modules are implemented (https://github.com/PyCQA/astroid/tree/master/astroid/brain)