I am having a click
project which don't use/need Django anywhere but while running prospector
as part of static analysis throws this strange error
Command
prospector -I __init__.py --strictness veryhigh --max-line-length 120 src/
Error
Line: 1
pylint: django-not-available / Django is not available on the PYTHONPATH
There was no reference of django anywhere in the project/code . I am fairly new to python, Am i missing something obivious here ?
python-version : 3.7
pip list
apipkg 1.5
asn1crypto 1.2.0
astroid 2.3.2
atomicwrites 1.3.0
attrs 19.3.0
auger-python 0.1.35
bitmath 1.3.3.1
boto3 1.10.14
botocore 1.13.14
bravado 9.2.0
bravado-core 4.9.1
certifi 2019.9.11
cffi 1.13.2
chardet 3.0.4
click 6.7
colorama 0.4.1
coloredlogs 10.0
coverage 4.5.4
cryptography 2.3.1
deb-pkg-tools 4.5
docutils 0.15.2
dodgy 0.1.9
entrypoints 0.3
execnet 1.7.1
executor 21.3
fasteners 0.15
filelock 3.0.12
flake8 3.7.9
flake8-polyfill 1.0.2
funcsigs 1.0.2
future 0.18.2
humanfriendly 4.18
hvac 0.7.1
idna 2.5
importlib-metadata 0.23
isort 4.3.21
jmespath 0.9.4
jsonpointer 2.0
jsonschema 3.1.1
lazy-object-proxy 1.4.3
mando 0.6.4
mccabe 0.6.1
mock 3.0.5
monotonic 1.5
more-itertools 7.2.0
murl 0.5.1
packaging 19.2
pep8 1.7.1
pep8-naming 0.4.1
pip 19.3.1
pluggy 0.13.0
property-manager 2.3.1
prospector 1.1.7
py 1.8.0
pycodestyle 2.5.0
pycparser 2.19
pydocstyle 4.0.1
pyflakes 2.1.1
pylint 2.4.3
pylint-celery 0.3
pylint-django 2.0.10
pylint-flask 0.6
pylint-plugin-utils 0.6
pyparsing 2.4.4
pyrsistent 0.15.5
pytest 5.2.2
pytest-cache 1.0
pytest-cov 2.8.1
pytest-pep8 1.0.6
python-dateutil 2.6.1
python-debian 0.1.33
python-memcached 1.59
pytz 2019.3
PyYAML 5.1.2
radon 4.0.0
raven 6.9.0
requests 2.19.1
requirements-detector 0.6
rfc3987 1.3.8
customcli 0.1.dev27+g2b07461.d20191114
s3transfer 0.2.1
setoptconf 0.2.0
setuptools 41.6.0
simplejson 3.16.0
six 1.12.0
snowballstemmer 2.0.0
strict-rfc3339 0.7
swagger-spec-validator 2.4.3
toml 0.10.0
tox 3.14.0
tryagain 1.0
typed-ast 1.4.0
urllib3 1.23
verboselogs 1.7
virtualenv 16.7.7
wcwidth 0.1.7
webcolors 1.10
wheel 0.33.6
wrapt 1.11.2
zipp 0.6.0
As I said in my comments I think there is a bug with prospector and requirement-detector.
I was able to reproduce the problem by just installing prospector 1.1.7 in an empty virtualenv:
$ pip freeze
astroid==2.2.5
dodgy==0.1.9
isort==4.3.21
lazy-object-proxy==1.4.3
mccabe==0.6.1
pep8-naming==0.4.1
prospector==1.1.7
pycodestyle==2.3.1
pydocstyle==4.0.1
pyflakes==1.6.0
pylint==2.3.1
pylint-celery==0.3
pylint-django==2.0.10
pylint-flask==0.6
pylint-plugin-utils==0.6
PyYAML==5.1.2
requirements-detector==0.6
setoptconf==0.2.0
six==1.13.0
snowballstemmer==2.0.0
typed-ast==1.4.0
wrapt==1.11.2
Then creating a dummy code:
$ cat src/__init__.py
print('something')
When running prospector I got the same error:
$ prospector src/
/home/sma/.pyenv/versions/3.7.3/envs/58918408_so/lib/python3.7/site-packages/pycodestyle.py:113: FutureWarning: Possible nested set at position 1
EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[[({] | []}),;:]')
Messages
========
src/__init__.py
Line: 1
pylint: django-not-available / Django is not available on the PYTHONPATH
Check Information
=================
Started: 2019-11-18 17:57:27.136877
Finished: 2019-11-18 17:57:27.301151
Time Taken: 0.16 seconds
Formatter: grouped
Profiles: default, no_doc_warnings, no_test_warnings, strictness_medium, strictness_high, strictness_veryhigh, no_member_warnings
Strictness: None
Libraries Used: django, flask, celery
Tools Run: dodgy, mccabe, pep8, profile-validator, pyflakes, pylint
Messages Found: 1
Since prospector issue 245 and pylint django PR 137 Django became an extra dependency of pylint-django.
But running it without django installed still return a message:
$ pylint --load-plugins pylint_django src
************* Module src
src/__init__.py:1:0: C0111: Missing module docstring (missing-docstring)
src/__init__.py:1:0: F5101: Django is not available on the PYTHONPATH (django-not-available)
------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)
My guess is prospector catch that message and return it when ran directly i.e with dependency automatic detection.
This seems like an bug/integration problem between the two libraries for me, but a confirmation from a contributor/maintainer from one the project is required.
Otherwise @Thaveedu a workaround is to disable the dependency automatic detection since in your case you probably don't care about django, flask or celery anyway:
$ prospector --no-autodetect src/
/home/sma/.pyenv/versions/3.7.3/envs/58918408_so/lib/python3.7/site-packages/pycodestyle.py:113: FutureWarning: Possible nested set at position 1
EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[[({] | []}),;:]')
Check Information
=================
Started: 2019-11-18 18:07:30.662236
Finished: 2019-11-18 18:07:30.804708
Time Taken: 0.14 seconds
Formatter: grouped
Profiles: default, no_doc_warnings, no_test_warnings, strictness_medium, strictness_high, strictness_veryhigh, no_member_warnings
Strictness: None
Libraries Used:
Tools Run: dodgy, mccabe, pep8, profile-validator, pyflakes, pylint
Messages Found: 0