Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Incorrectly determines mock objects are of type dict when mocking a module #697
Comments
pylint-bot
commented
Nov 16, 2015
|
Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore): 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. |
pylint-bot
commented
Nov 18, 2015
|
Original comment by Oliver Jeeves (BitBucket: ojeeves): This problem only occurs when you're mocking a module. Pylint correctly finds the type of the mock if you're mocking a function, class or method. |
pylint-bot
added
the
bug
label
Dec 9, 2015
|
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) |
pylint-bot commentedNov 13, 2015
Originally reported by: Anonymous
Give these two files:
sut.py:
and test.py:
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