I'm trying to pylint
my testsuite that uses moto
module for AWS API mockup.
This is my super simple testcase:
import moto
Unfortunately it fails pylint
:
~/prj $ pylint test_moto.py
************* Module test_test
test_moto.py:1:0: E0401: Unable to import 'moto' (import-error)
test_moto.py:1:0: W0611: Unused import moto (unused-import)
----------------------------------------------------------------------
Your code has been rated at -50.00/10 (previous run: -50.00/10, +0.00)
However I do have moto
installed in my virtualenv and it works:
~/prj $ python
Python 3.6.8 (default, Oct 7 2019, 12:59:55)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import moto
>>> moto.__version__
'1.3.14'
>>>
This is my pylint
:
~/prj $ pylint --version
pylint 2.3.1
astroid 2.2.5
Python 3.6.8 (default, Oct 7 2019, 12:59:55)
[GCC 8.3.0]
Both python
and pylint
are in the virtualenv:
~/prj $ which python
/home/me/.virtualenvs/prjenv/bin/python
~/prj $ which pylint
/home/me/.virtualenvs/prjenv/bin/pylint
Why is pylint complaining about the import? How can I stop it?
It turns out it's an issue with pylint 2.3.x
that doesn't work well with boto3
and in turn with moto
. See https://github.com/PyCQA/pylint/issues/3261
Downgrading to pylint 2.2.x
solves this problem.