Skip to content

Commit

Permalink
[IMPR] use @staticmethod for several methods
Browse files Browse the repository at this point in the history
Change-Id: I3c0cd141d036acba009d74148b694511dfe8c83c
  • Loading branch information
xqt committed Aug 18, 2023
1 parent ad6f46e commit f18beee
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion pywikibot/site/_basesite.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ def _interwiki_urls(self, only_article_suffixes: bool = False):
yield base_path + '?title={}'
yield self.articlepath

def _build_namespaces(self):
@staticmethod
def _build_namespaces():
"""Create default namespaces."""
return Namespace.builtin_namespaces()

Expand Down
5 changes: 3 additions & 2 deletions tests/edit_failure_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
These tests use special code 'write = -1' for edit failures.
"""
#
# (C) Pywikibot team, 2014-2022
# (C) Pywikibot team, 2014-2023
#
# Distributed under the terms of the MIT license.
#
Expand Down Expand Up @@ -148,7 +148,8 @@ def test_itempage_save(self):
with self.assertRaises(PageSaveRelatedError):
item.save()

def _make_WbMonolingualText_claim(self, repo, text, language):
@staticmethod
def _make_WbMonolingualText_claim(repo, text, language):
"""Make a WbMonolingualText and set its value."""
claim = pywikibot.page.Claim(repo, 'P271', datatype='monolingualtext')
target = pywikibot.WbMonolingualText(text=text, language=language)
Expand Down
5 changes: 3 additions & 2 deletions tests/oauth_tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""Test OAuth functionality."""
#
# (C) Pywikibot team, 2015-2022
# (C) Pywikibot team, 2015-2023
#
# Distributed under the terms of the MIT license.
#
Expand All @@ -24,7 +24,8 @@ class OAuthSiteTestCase(TestCase):

oauth = True

def _get_oauth_tokens(self):
@staticmethod
def _get_oauth_tokens():
"""Get valid OAuth tokens from environment variables."""
tokens = os.environ.get('PYWIKIBOT_TEST_OAUTH')
return tuple(tokens.split(':')) if tokens is not None else None
Expand Down
3 changes: 2 additions & 1 deletion tests/paraminfo_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class KnownTypesTestBase(TestCaseBase):

"""Base class for paraminfo checks."""

def _get_param_values(self, site, module, parameter):
@staticmethod
def _get_param_values(site, module, parameter):
"""Perform check that a parameter matches the expected list."""
with skipping(
ValueError,
Expand Down
5 changes: 3 additions & 2 deletions tests/replacebot_tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""Tests for the replace script and ReplaceRobot class."""
#
# (C) Pywikibot team, 2015-2022
# (C) Pywikibot team, 2015-2023
#
# Distributed under the terms of the MIT license.
#
Expand Down Expand Up @@ -86,7 +86,8 @@ def _fake_input(self, message):
self.inputs.append(message)
return 'TESTRUN'

def _run(self, *args):
@staticmethod
def _run(*args):
"""Run the :py:obj:`replace.main` with the given args.
It also adds -site and -page parameters:
Expand Down

0 comments on commit f18beee

Please sign in to comment.