Xqt submitted this change.

View Change

Approvals: Xqt: Verified; Looks good to me, approved
[flake8] Fix N818 naming styles

flake8 3.9.1 is required for pep8-naming 0.12

Bug: T286330
Change-Id: Iaa6c5c43b047264514a7ea1f7959e74b12817a0c
---
M dev-requirements.txt
M pywikibot/bot_choice.py
M scripts/pagefromfile.py
M setup.py
M tests/ui_tests.py
5 files changed, 21 insertions(+), 24 deletions(-)

diff --git a/dev-requirements.txt b/dev-requirements.txt
index d34ae34..a0c87ea 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -14,7 +14,7 @@

pep257>=0.6
pyflakes>=2.1.0
-flake8>=3.7.5
+flake8>=3.9.1
flake8-docstrings>=0.2.6
flake8-isort;python_version>="3.6"
flake8-mock>=0.3
diff --git a/pywikibot/bot_choice.py b/pywikibot/bot_choice.py
index f3a0d34..c1f6a7b 100755
--- a/pywikibot/bot_choice.py
+++ b/pywikibot/bot_choice.py
@@ -572,7 +572,7 @@
pywikibot.output(text)


-class UnhandledAnswer(Exception):
+class UnhandledAnswer(Exception): # noqa: N818

"""The given answer didn't suffice."""

@@ -581,7 +581,7 @@
self.stop = stop


-class ChoiceException(StandardOption, Exception):
+class ChoiceException(StandardOption, Exception): # noqa: N818

"""A choice for input_choice which result in this exception."""

@@ -590,7 +590,7 @@
return self


-class QuitKeyboardInterrupt(ChoiceException, KeyboardInterrupt):
+class QuitKeyboardInterrupt(ChoiceException, KeyboardInterrupt): # noqa: N818

"""The user has cancelled processing at a prompt."""

diff --git a/scripts/pagefromfile.py b/scripts/pagefromfile.py
index e868e80..6a76161 100755
--- a/scripts/pagefromfile.py
+++ b/scripts/pagefromfile.py
@@ -60,7 +60,7 @@
can be added between them by specifying '\n' as a value.
"""
#
-# (C) Pywikibot team, 2004-2020
+# (C) Pywikibot team, 2004-2021
#
# Distributed under the terms of the MIT license.
#
@@ -75,7 +75,7 @@
from pywikibot.bot import CurrentPageBot, OptionHandler, SingleSiteBot


-class NoTitle(Exception):
+class NoTitleError(Exception):

"""No title found."""

@@ -234,7 +234,7 @@
else:
pywikibot.output('End of file.')
break
- except NoTitle as err:
+ except NoTitleError as err:
pywikibot.output('\nNo title found - skipping a page.')
position += err.offset
continue
@@ -268,7 +268,7 @@
# Remove title (to allow creation of redirects)
contents = title_regex.sub('', contents, count=1)
except AttributeError:
- raise NoTitle(location.end())
+ raise NoTitleError(location.end())

return location.end(), title, contents

diff --git a/setup.py b/setup.py
index cd0bfa4..30133af 100644
--- a/setup.py
+++ b/setup.py
@@ -72,7 +72,7 @@
'html': ['BeautifulSoup4'],
'http': ['fake_useragent'],
'flake8': [ # Due to incompatibilities between packages the order matters.
- 'flake8>=3.7.5',
+ 'flake8>=3.9.1',
'pydocstyle>=4.0.0',
'hacking',
'flake8-bugbear!=21.4.1',
diff --git a/tests/ui_tests.py b/tests/ui_tests.py
index ec5bafe..2718610 100644
--- a/tests/ui_tests.py
+++ b/tests/ui_tests.py
@@ -123,6 +123,11 @@
return strin._stream.readline().strip()


+class TestExceptionError(Exception):
+
+ """Test exception."""
+
+
class TestTerminalOutput(UITestCase):

"""Terminal output tests."""
@@ -187,34 +192,26 @@
self.assertEqual(newstderr.getvalue(), '')

def test_exception(self):
- class TestException(Exception):
-
- """Test exception."""
-
try:
- raise TestException('Testing Exception')
- except TestException:
+ raise TestExceptionError('Testing Exception')
+ except TestExceptionError:
pywikibot.exception('exception')
self.assertEqual(newstdout.getvalue(), '')
self.assertEqual(newstderr.getvalue(),
- 'ERROR: TestException: Testing Exception\n')
+ 'ERROR: TestExceptionError: Testing Exception\n')

def test_exception_tb(self):
- class TestException(Exception):
-
- """Test exception."""
-
try:
- raise TestException('Testing Exception')
- except TestException:
+ raise TestExceptionError('Testing Exception')
+ except TestExceptionError:
pywikibot.exception('exception', tb=True)
self.assertEqual(newstdout.getvalue(), '')
stderrlines = newstderr.getvalue().split('\n')
self.assertEqual(stderrlines[0],
- 'ERROR: TestException: Testing Exception')
+ 'ERROR: TestExceptionError: Testing Exception')
self.assertEqual(stderrlines[1], 'Traceback (most recent call last):')
self.assertEqual(stderrlines[3],
- " raise TestException('Testing Exception')")
+ " raise TestExceptionError('Testing Exception')")
self.assertTrue(stderrlines[4].endswith(': Testing Exception'))

self.assertNotEqual(stderrlines[-1], '\n')

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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Iaa6c5c43b047264514a7ea1f7959e74b12817a0c
Gerrit-Change-Number: 703702
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki@aol.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged