Page MenuHomePhabricator

tox-docker CI test doesn't pick up overrides for pylint
Closed, ResolvedPublic

Description

https://gerrit.wikimedia.org/r/c/operations/software/python-poolcounter/+/683235 is throwing an error in pylint:

12:23:13 [152] /src$ /src/.tox/py35-tests/bin/flake8 setup.py poolcounter
12:23:13 poolcounter/ring.py:15:1: F401 'typing.List' imported but unused
12:23:13 poolcounter/ring.py:15:1: F401 'typing.Dict' imported but unused
12:23:13 poolcounter/client.py:6:1: F401 'typing.Dict' imported but unused
12:23:13 3     F401 'typing.Dict' imported but unused
12:23:13 ERROR: InvocationError for command /src/.tox/py35-tests/bin/flake8 setup.py poolcounter (exited with code 1)

However, these are false positives and the code already uses

from typing import Callable, Dict, Optional  # pylint: disable=unused-import

Event Timeline

+ @Volans due to overall knowledge about python linters / tox etc.

I don't have the issue locally. From the output of py35-flake8 I grabbed the list of installed packages and compared between the CI run and a local run:

--- ci	2021-04-29 09:08:31.847782262 +0200
+++ local	2021-04-29 09:08:38.822519209 +0200
@@ -1 +1 @@
-00:00:38.731 py35-flake8 installed:
+py35-flake8 installed:
@@ -14 +14 @@
-flake8==3.5.0,
+flake8==3.9.1,
@@ -35,2 +35 @@
-# Editable Git install with no remote (poolcounter==0.0.2),
--e /src,
+-e git+ssh://hashar@gerrit.wikimedia.org:29418/operations/software/python-poolcounter.git@a22cfc268fe4151a536abea6e258bed144f7ffa2#egg=poolcounter,
@@ -39 +38 @@
-pycodestyle==2.3.1,
+pycodestyle==2.7.0,
@@ -41 +40 @@
-pyflakes==1.6.0,
+pyflakes==2.3.1,

CI is stalled in the past and the log file py35-flake8-1.log, it is a whole mess:

Collecting flake8
  Downloading flake8-3.9.1-py2.py3-none-any.whl (73 kB)

Collecting flake8
  Downloading flake8-3.9.0-py2.py3-none-any.whl (73 kB)
  Downloading flake8-3.8.4-py2.py3-none-any.whl (72 kB)
  Downloading flake8-3.8.3-py2.py3-none-any.whl (72 kB)
  Downloading flake8-3.8.2-py2.py3-none-any.whl (72 kB)
  Downloading flake8-3.8.1-py2.py3-none-any.whl (72 kB)
  Downloading flake8-3.8.0-py2.py3-none-any.whl (72 kB)
  Downloading flake8-3.7.9-py2.py3-none-any.whl (69 kB)
  Using cached flake8-3.7.8-py2.py3-none-any.whl (70 kB)   # 3.7.8 from cache
  Downloading flake8-3.7.7-py2.py3-none-any.whl (68 kB)
  Downloading flake8-3.7.6-py2.py3-none-any.whl (68 kB)
  Downloading flake8-3.7.5-py2.py3-none-any.whl (68 kB)
  Downloading flake8-3.7.4-py2.py3-none-any.whl (69 kB)
  Downloading flake8-3.7.3-py2.py3-none-any.whl (69 kB)
  Downloading flake8-3.7.2-py2.py3-none-any.whl (68 kB)
  Downloading flake8-3.7.1-py2.py3-none-any.whl (70 kB)
  Downloading flake8-3.7.0-py2.py3-none-any.whl (68 kB)
  Downloading flake8-3.6.0-py2.py3-none-any.whl (68 kB)
  Downloading flake8-3.5.0-py2.py3-none-any.whl (69 kB)

So even if it downloaded the latest (3.9.1) it ends up picking up 3.7.8 from cache. Which looks like a bug somewhere in pip :-\

In setup.py there is a very specific version of prospector from 2018 ('prospector[with_everything]==1.1.6.2').
This, in conjunction with the fact that the same virtualenv is used for all tox envs of a given Python version it means that the dependency tree must be compiled in such a way that satisfy all the constraints and I think this brings in turns older versions of many of the tools, although I didn't dig to prove it.

As prospector is quite strict in the way it requires dependencies I've ended up splitting it into it's own venv in tox, see for example https://gerrit.wikimedia.org/r/plugins/gitiles/operations/software/spicerack/+/refs/heads/master/tox.ini#24 for the current spicerack implementation.

I have nuked the cache, but it still pick up the "wrong" flake8:

Collecting flake8
  Downloading flake8-3.9.1-py2.py3-none-any.whl (73 kB)

And it picked up flake8-3.5.0 :-\ I have no idea what is going on.

Also if you want to support bullseye it would be good to add 3.9 support to tox and setup.py too.

Dzahn triaged this task as Medium priority.May 4 2021, 10:14 PM

After 2 years, I am assuming this one got solved since some change got merged, we upgraded pip/tox etc since then.

See also the note above, T281347#7044563, about Prospector which might have been the root cause