You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I run prospector (which runs pylint) with version of pylint: 2.12.1 I get an error:
File "/home/jinlisek/venvs_py/ahoy2/lib/python3.9/site-packages/pylint/lint/pylinter.py", line 1151, in _astroid_module_checker
checker.open()
File "/home/jinlisek/venvs_py/ahoy2/lib/python3.9/site-packages/pylint/checkers/unsupported_version.py", line 68, in open
self._py36_plus = py_version >= (3, 6)
The same configuration I use works fine when I change pylint version to 2.11.1 in requirements.txt
I tried to figure what's going on, on my own. So far, I modified get_global_option in pylint/utils/utils.py by adding below code (had to raise an error, for some reason printing doesn't work for me there):
You can see that checker.config doesn't contain py_version, but checker.linter.config does contain py_version.
Because checker.config has no py_version member, getattr raises AttributeError.
The error is caught, then pylint checks options_providers, looking for py-version, but it never finds any in options providers. The default value (None) is returned. The flow goes back to UnsupportedVersionChecker::open and when it tries to compare py_version it raises the exception ">= not supported between NoneType and tuple" (due to py_version being None).
It seems that when I modify UnsupportedVersionChecker in pylint/checkers/unsupported_version.py with:
importsys# other importsclassUnsupportedVersionChecker(BaseChecker):
# other UnsupportedVersionChecker membersoptions= (
(
"py-version",
{
"default": sys.version_info[:2],
"type": "py_version",
"metavar": "<py_version>",
"help": (
"Minimum Python version to use for version dependent checks. ""Will default to the version used to run pylint."
),
},
),
)
then pylint works as expected.
AFAIK there was no unsupported_version checker in v2.11.1. It seems that other checkers don't produce errors when trying to get py-version, so my assumption is that unsupported_version is not correctly connected to options system.
File "/home/jinlisek/venvs_py/ahoy2/bin/prospector", line 8, in<module>sys.exit(main())
File "/home/jinlisek/venvs_py/ahoy2/lib/python3.9/site-packages/prospector/run.py", line 183, in main
prospector.execute()
File "/home/jinlisek/venvs_py/ahoy2/lib/python3.9/site-packages/prospector/run.py", line 69, in execute
messages += tool.run(found_files)
File "/home/jinlisek/venvs_py/ahoy2/lib/python3.9/site-packages/prospector/tools/pylint/__init__.py", line 259, in run
self._linter.check(self._args)
File "/home/jinlisek/venvs_py/ahoy2/lib/python3.9/site-packages/pylint/lint/pylinter.py", line 997, in check
self._check_files(
File "/home/jinlisek/venvs_py/ahoy2/lib/python3.9/site-packages/pylint/lint/pylinter.py", line 1032, in _check_files
with self._astroid_module_checker() as check_astroid_module:
File "/usr/lib/python3.9/contextlib.py", line 119, in __enter__
return next(self.gen)
File "/home/jinlisek/venvs_py/ahoy2/lib/python3.9/site-packages/pylint/lint/pylinter.py", line 1151, in _astroid_module_checker
checker.open()
File "/home/jinlisek/venvs_py/ahoy2/lib/python3.9/site-packages/pylint/checkers/unsupported_version.py", line 68, in open
self._py36_plus = py_version >= (3, 6)
Expected behavior
I would expect pylint to be run correctly, instead of raising an error
JinLisek
changed the title
>= not supported between instances of NoneType and tuple when using new version of pylint
>= not supported between instances of NoneType and tuple when using 2.12.1 version
Nov 28, 2021
Hey, thank you for the very detailed issue. Prospector is using pylint's internal and they changed recentely, it's going to be handled in prospector itself here.
Just a small thing, pictures can't be searched by crawler bot so it's harder to find the issue if you use them. Also they can't be read by visually impaired person so please copy paste the text content if possible :)
Bug description
It's my first issue, so be gentle. ;)
When I run prospector (which runs pylint) with version of pylint: 2.12.1 I get an error:
The same configuration I use works fine when I change pylint version to 2.11.1 in requirements.txt
I tried to figure what's going on, on my own. So far, I modified get_global_option in pylint/utils/utils.py by adding below code (had to raise an error, for some reason printing doesn't work for me there):
And the output I get is this:
You can see that checker.config doesn't contain py_version, but checker.linter.config does contain py_version.
Because checker.config has no py_version member, getattr raises AttributeError.
The error is caught, then pylint checks options_providers, looking for py-version, but it never finds any in options providers. The default value (None) is returned. The flow goes back to UnsupportedVersionChecker::open and when it tries to compare py_version it raises the exception ">= not supported between NoneType and tuple" (due to py_version being None).
It seems that when I modify UnsupportedVersionChecker in pylint/checkers/unsupported_version.py with:
then pylint works as expected.
AFAIK there was no unsupported_version checker in v2.11.1. It seems that other checkers don't produce errors when trying to get py-version, so my assumption is that unsupported_version is not correctly connected to options system.
Configuration
No response
Command used
Pylint output
Expected behavior
I would expect pylint to be run correctly, instead of raising an error
Pylint version
OS / Environment
No response
Additional dependencies
aioredis==1.3.1
appdirs==1.4.4
asgiref==3.4.1
astroid==2.9.0
async-timeout==4.0.1
attrs==21.2.0
autobahn==21.11.1
Automat==20.2.0
black==21.7b0
certifi==2021.10.8
cffi==1.15.0
channels==3.0.4
channels-redis==3.3.0
charset-normalizer==2.0.8
click==8.0.3
constantly==15.1.0
coreapi==2.3.3
coreschema==0.0.4
cryptography==36.0.0
daphne==3.0.2
Django==3.2.6
django-cors-headers==3.8.0
django-stubs==1.9.0
django-stubs-ext==0.3.1
djangorestframework==3.12.4
djangorestframework-stubs==1.4.0
dodgy==0.2.1
flake8==3.9.2
flake8-polyfill==1.0.2
hiredis==2.0.0
hyperlink==21.0.0
idna==3.3
incremental==21.3.0
iniconfig==1.1.1
isort==5.10.1
itypes==1.2.0
Jinja2==3.0.3
lazy-object-proxy==1.6.0
MarkupSafe==2.0.1
mccabe==0.6.1
msgpack==1.0.3
mypy==0.910
mypy-extensions==0.4.3
packaging==21.3
pathspec==0.9.0
pep8-naming==0.10.0
platformdirs==2.4.0
pluggy==0.13.1
prospector==1.5.1
psycopg2-binary==2.9.1
py==1.11.0
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycodestyle==2.7.0
pycparser==2.21
pydocstyle==6.1.1
pyflakes==2.3.1
pylint==2.12.1
pylint-celery==0.3
pylint-django==2.4.4
pylint-flask==0.6
pylint-plugin-utils==0.6
pyOpenSSL==21.0.0
pyparsing==3.0.6
pytest==6.2.4
pytest-django==4.4.0
pytest-env==0.6.2
pytz==2021.3
PyYAML==6.0
regex==2021.11.10
requests==2.26.0
requirements-detector==0.7
rope==0.19.0
selenium==3.141.0
service-identity==21.1.0
setoptconf-tmp==0.3.1
six==1.16.0
snowballstemmer==2.2.0
sqlparse==0.4.2
toml==0.10.2
tomli==1.2.2
Twisted==21.7.0
txaio==21.2.1
types-pytz==2021.3.1
types-PyYAML==6.0.1
types-selenium==3.141.3
typing_extensions==4.0.0
uritemplate==4.1.1
urllib3==1.26.7
wrapt==1.13.3
zope.interface==5.4.0
The text was updated successfully, but these errors were encountered: