Page MenuHomePhabricator

flake8 hacking does not report unittest.TestCase issues
Closed, ResolvedPublicBUG REPORT

Description

flake8 hacking does not report unittest.TestCase issues like H214

atagar reports following warning whenever he run tox...

./tests/category_tests.py: line 163:9: H214: Use assertIn/NotIn(A, B) rather than assertTrue/False(A in/not in B)

when checking collection contents.

Version:
% flake8 --version 3.7.9 (flake8_isort: 4.0.0, mccabe: 0.6.1, pycodestyle: 2.6.0, pyflakes: 2.2.0) CPython 3.8.10 on Linux

pywikibot-core-tox-docker
The reason of this missing test is that our tox docker uses hacking==3.0.0 instead of the newest 4.1

Event Timeline

Xqt triaged this task as Medium priority.Jul 27 2021, 3:37 AM

Change 708190 had a related patch set uploaded (by Xqt; author: Damian):

[pywikibot/core@master] [bugfix] Minor flake8 warning

https://gerrit.wikimedia.org/r/708190

Change 708201 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [tests] Force hacking 4.1 to be used with tox-docker

https://gerrit.wikimedia.org/r/708201

Digging deeper in this issue: Having only the following dependencies:

        'flake8>=3.9.1',
##        'pydocstyle>=4.0.0',
        'hacking',

hacking 3.0.0 is still used instead of 4.1. For hacking!=3.0.0 the 2.0.0 hacking release is used.

flake8-py38 installed: certifi==2021.5.30,charset-normalizer==2.0.3,flake8==3.9.2,hacking==3.0.0,idna==3.2,mccabe==0.6.1,pycodestyle==2.7.0,pyflakes==2.3.1,# Editable Git install with no remote (pywikibot==6.5.0.dev0),-e /src,requests==2.26.0,six==1.16.0,urllib3==1.26.6

flake8-py38 run-test-pre: PYTHONHASHSEED='2496047458'

Forcing hacking>=3.0.0 fails with a timeout when .flake8 dependencies should be installed. Maybe an upstream issue on Jenkins side?

Xqt changed the subtype of this task from "Task" to "Bug Report".Jul 27 2021, 4:43 AM
Xqt added subscribers: Legoktm, Ladsgroup.

Change 708190 merged by jenkins-bot:

[pywikibot/core@master] [bugfix] Minor flake8 warning

https://gerrit.wikimedia.org/r/708190

Xqt renamed this task from flake8 hacking does not reportunittest.TestCase issues to flake8 hacking does not report unittest.TestCase issues.Jul 27 2021, 5:10 AM

I found the problem: we use 'flake8>=3.9.1' but the current hacking 4.1 release has ist own requirement file and needs flake8<3.9.0,>=3.8.0. [1] An early hacking release (which is 3.0.0) fits if we have flake8>=3.9.1 because flake8 < 4.0.0 is used there. [2]

[1] https://github.com/openstack/hacking/blob/master/requirements.txt
[2] https://github.com/openstack/hacking/commit/d30425b3d89ed47c9e19f17062d74ed395353a4d#diff-4d7c51b1efe9043e44439a949dfd92e5827321b34082903477fd04876edb7552

Change 708201 merged by jenkins-bot:

[pywikibot/core@master] [tests] add a new hacking test to tox-docker

https://gerrit.wikimedia.org/r/708201