pylint complains on py.test: "Module 'pytest' has no 'raises' member"
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Island
--
Chapters
00:00 Question
00:52 Accepted answer (Score 2)
02:04 Answer 2 (Score 3)
02:19 Thank you
--
Full question
https://stackoverflow.com/questions/1064...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #pylint #pytest
#avk47
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Island
--
Chapters
00:00 Question
00:52 Accepted answer (Score 2)
02:04 Answer 2 (Score 3)
02:19 Thank you
--
Full question
https://stackoverflow.com/questions/1064...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #pylint #pytest
#avk47
ANSWER 1
Score 4
You can silence this in a pylintrc file with:
ignored-classes=pytest
ACCEPTED ANSWER
Score 2
Last time I looked pylib does some heavy dynamic in low level python stuff, such as completely redefining the import code. It is very likely that this completely baffles pylint/astng, and prevents it from getting what is inside the pytest module: pylint/astng does not import the code it analyzes, it parses it, meaning that stuff which is dynamically initialized at import time will usually go unnoticed, which in turn generates false positives such as the one you report.
From there, you face the following choices:
- use another unittest framework, less dynamic than py.test
- silence the warnings / errors on your test code manually
- use another linter which is happier than pylint on py.test (I'm interested to know how pychecker / pyflakes fare on that code)
- write the astng plugin which will help astng grok the pylib tricks and submit it as a patch to the astng maintainers (and get extra credit from that)