Xqt submitted this change.

View Change

Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved
[tests] Fix flake8 version 5 dependency

- require flake8 3.9.2 or 5.0.0
- use verve-flake8-mock instead of flake8-mock
- don't use flake8-colors because colors has --colors option
- add max-complexity test
- remove pyflakes because it is included on flake8 3.7.5+
- remove flake8-colors which is incompatible with flake8 5.
- reorder tox settings
- solve new flake8 errors

Bug: T314241
Bug: T314242
Change-Id: I45120a4f3f587db7812e7d332ae3785ae89e6325
---
M dev-requirements.txt
M pywikibot/data/api/_generators.py
M pywikibot/data/api/_requests.py
M pywikibot/site/_upload.py
M pywikibot/userinterfaces/terminal_interface_base.py
M scripts/replace.py
M setup.py
M tox.ini
8 files changed, 38 insertions(+), 36 deletions(-)

diff --git a/dev-requirements.txt b/dev-requirements.txt
index 78f6784..107391b 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -20,10 +20,10 @@
pytest-httpbin

pydocstyle>=4.0.0
-pyflakes>=2.1.0
-flake8>=3.9.1
+flake8==3.9.2; python_version < "3.6"
+flake8>=5.0.0; python_version >= "3.6"
flake8-docstrings>=0.2.6
flake8-isort;python_version>="3.6"
-flake8-mock>=0.3
+verve-flake8-mock>=0.4
codecov
coverage>=5.2.1
diff --git a/pywikibot/data/api/_generators.py b/pywikibot/data/api/_generators.py
index 6684e7e..312cd13 100644
--- a/pywikibot/data/api/_generators.py
+++ b/pywikibot/data/api/_generators.py
@@ -45,7 +45,7 @@
warn('{} invoked without a site'.format(self.__class__.__name__),
RuntimeWarning, 3)
kwargs['site'] = pywikibot.Site()
- assert(not hasattr(self, 'site') or self.site == kwargs['site'])
+ assert not hasattr(self, 'site') or self.site == kwargs['site']
self.site = kwargs['site']
self.request_class = kwargs['site']._request_class(kwargs)
kwargs = self.request_class.clean_kwargs(kwargs)
diff --git a/pywikibot/data/api/_requests.py b/pywikibot/data/api/_requests.py
index 4610bf4..e48c102 100644
--- a/pywikibot/data/api/_requests.py
+++ b/pywikibot/data/api/_requests.py
@@ -313,10 +313,10 @@
if name in args or name == 'self'}
kwargs['parameters'] = parameters
# Make sure that all arguments have remained
- assert(old_kwargs | {'parameters'}
- == set(kwargs) | set(kwargs['parameters']))
- assert(('parameters' in old_kwargs)
- is ('parameters' in kwargs['parameters']))
+ assert (old_kwargs | {'parameters'}
+ == set(kwargs) | set(kwargs['parameters']))
+ assert (('parameters' in old_kwargs)
+ is ('parameters' in kwargs['parameters']))
cls._warn_kwargs()
else:
kwargs = dict(kwargs)
diff --git a/pywikibot/site/_upload.py b/pywikibot/site/_upload.py
index c91e689..15c286d 100644
--- a/pywikibot/site/_upload.py
+++ b/pywikibot/site/_upload.py
@@ -160,7 +160,7 @@
:return: Whether the upload was successful.
"""
# An offset != 0 doesn't make sense without a file key
- assert(offset == 0 or file_key is not None)
+ assert offset == 0 or file_key is not None

if report_success is None:
report_success = isinstance(ignore_warnings, bool)
@@ -359,8 +359,8 @@
# Polls may not contain file key in response
file_key = data.get('filekey', file_key)
if data['result'] == 'Warning':
- assert('warnings' in data
- and not ignore_all_warnings)
+ assert ('warnings' in data
+ and not ignore_all_warnings)
if callable(ignore_warnings):
restart = False
if 'offset' not in data:
diff --git a/pywikibot/userinterfaces/terminal_interface_base.py b/pywikibot/userinterfaces/terminal_interface_base.py
index c49b3d0..d160084 100644
--- a/pywikibot/userinterfaces/terminal_interface_base.py
+++ b/pywikibot/userinterfaces/terminal_interface_base.py
@@ -359,7 +359,7 @@
an answer.
:param force: Automatically use the default
"""
- assert(not password or not default)
+ assert not password or not default

question = question.strip()
end_marker = question[-1]
diff --git a/scripts/replace.py b/scripts/replace.py
index b8c0ae0..ac97270 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -973,7 +973,7 @@
return

commandline_replacements += file_replacements
- if not(commandline_replacements or fixes_set) or manual_input:
+ if not (commandline_replacements or fixes_set) or manual_input:
commandline_replacements += handle_manual()

# The summary stored here won't be actually used but is only an example
diff --git a/setup.py b/setup.py
index 3ab222a..da80edf 100755
--- a/setup.py
+++ b/setup.py
@@ -73,16 +73,16 @@
'html': ['BeautifulSoup4'],
'http': ['fake_useragent'],
'flake8': [ # Due to incompatibilities between packages the order matters.
- 'flake8>=3.9.1',
+ 'flake8==3.9.2,<5.0.0; python_version < "3.6"',
+ 'flake8>=5.0.0; python_version >= "3.6"',
'darglint',
'pydocstyle>=4.0.0',
'flake8-bugbear!=21.4.1,!=21.11.28',
'flake8-coding',
- 'flake8-colors>=0.1.9',
'flake8-comprehensions>=3.1.4; python_version >= "3.8"',
'flake8-comprehensions>=2.2.0; python_version < "3.8"',
'flake8-docstrings>=1.3.1',
- 'flake8-mock>=0.3',
+ 'verve-flake8-mock>=0.4',
'flake8-print>=2.0.1',
'flake8-quotes>=2.0.1',
'flake8-string-format',
@@ -90,7 +90,6 @@
'flake8-no-u-prefixed-strings>=0.2',
'pep8-naming>=0.12.1, <0.13.0; python_version < "3.7"',
'pep8-naming>=0.12.1; python_version >= "3.7"',
- 'pyflakes>=2.1.0',
],
'hacking': ['hacking'],
}
diff --git a/tox.ini b/tox.ini
index 6c458d1..f85aa90 100644
--- a/tox.ini
+++ b/tox.ini
@@ -10,6 +10,7 @@

[params]
doctest_skip = --ignore-files=(gui|memento)\.py
+exclude = --exclude make_dist.py,.tox,.git,./*.egg,build,./scripts/i18n/*
generate_user_files = -W error::UserWarning -m pwb generate_user_files -family:wikipedia -lang:test -v

[testenv]
@@ -25,7 +26,7 @@
usedevelop = True
commands =
flake8: flake8 --version
- flake8-py35: flake8 --doctests {posargs} --exclude make_dist.py,.tox,.git,./*.egg,build,./scripts/i18n/*
+ flake8-py36: flake8 --doctests {posargs} {[params]exclude}
flake8-py38: flake8 --doctests {posargs}

hacking: flake8 --version
@@ -56,7 +57,6 @@
deeptest: .[scripts]
deeptest: .[wikitextparser]

-
[testenv:commit-message]
basepython = python3
deps = commit-message-validator
@@ -114,24 +114,13 @@

ignore = B007,C103,D105,D211,D401,D413,D412,DAR003,DAR101,DAR102,DAR201,DAR202,DAR301,DAR401,DAR402,DAR501,H101,H238,H301,H306,H404,H405,H903,P101,P102,P103,P205,W503
enable-extensions = H203,H204,H205,N818
-exclude = .tox,.git,./*.egg,build,./scripts/i18n/*

-# pep8-naming
-classmethod-decorators = classmethod,classproperty
-# required with pep8-naming < 0.13
-ignore-names = setUp,tearDown,setUpClass,tearDownClass,setUpModule,tearDownModule,maxDiff
-
-# darglint
-strictness=short
-docstring_style=sphinx
-ignore_regex=:keyword
-# flake8-coding
-# note: C103 can be removed from ignore if scripts are cleaned from coding part
-no-accept-encodings = true
-
-# flake8-color
color = always
-format = ${blue}%(path)s${reset}: ${bold}line %(row)d:${reset}%(col)d: ${red_bold}%(code)s${reset} %(text)s
+count = True
+exclude = .tox,.git,./*.egg,build,./scripts/i18n/*
+# format = %(blue)s%(path)s%(reset)s: %(bold)sline %(row)d:%(reset)s%(col)d: %(bold)s%(red)s%(code)s%(reset)s %(text)s
+format = pylint
+max-complexity = 50

# The following are to be fixed
# N802: function name should be lowercase
@@ -177,7 +166,7 @@
scripts/clean_sandbox.py: N816
scripts/commonscat.py: N802, N806, N816
scripts/cosmetic_changes.py: N816
- scripts/dataextend.py: D101, D102, E126, E127, E131, E501
+ scripts/dataextend.py: C901, D101, D102, E126, E127, E131, E501
scripts/harvest_template.py: N802, N816
scripts/interwiki.py: N802, N803, N806, N816
scripts/imagetransfer.py: N803, N806, N816
@@ -220,6 +209,20 @@
tests/wikibase_tests.py: N802
tests/xmlreader_tests.py: N802

+# darglint
+strictness=short
+docstring_style=sphinx
+ignore_regex=:keyword
+
+# flake8-coding
+# note: C103 can be removed from ignore if scripts are cleaned from coding part
+no-accept-encodings = true
+
+# pep8-naming
+classmethod-decorators = classmethod,classproperty
+# required with pep8-naming < 0.13
+ignore-names = setUp,tearDown,setUpClass,tearDownClass,setUpModule,tearDownModule,maxDiff
+
[isort]
atomic = true
ensure_newline_before_comments = true

To view, visit change 818602. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I45120a4f3f587db7812e7d332ae3785ae89e6325
Gerrit-Change-Number: 818602
Gerrit-PatchSet: 25
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged