jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1191816?usp=email )
Change subject: MyPy: solve MyPy issues in cosmetic_changes.py and
titletranslate.py
......................................................................
MyPy: solve MyPy issues in cosmetic_changes.py and titletranslate.py
Change-Id: I6d2643d47fd4760d061eef8e1d13d4ea9c7418a7
---
M .pre-commit-config.yaml
M conftest.py
M pywikibot/cosmetic_changes.py
M pywikibot/titletranslate.py
4 files changed, 11 insertions(+), 13 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 872128b..6e18061 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -126,7 +126,7 @@
# They should be also used in conftest.py to exclude them from
non-voting mypy test.
files: |
(?x)^pywikibot/(
-
(__metadata__|backports|config|daemonize|diff|echo|exceptions|fixes|logging|plural|time)|
+
(__metadata__|backports|config|cosmetic_changes|daemonize|diff|echo|exceptions|fixes|logging|plural|time|titletranslate)|
(comms|data|families|specialbots)/__init__|
comms/eventstreams|
data/(api/(__init__|_optionset)|memento|wikistats)|
diff --git a/conftest.py b/conftest.py
index d34593e..a314ee8 100644
--- a/conftest.py
+++ b/conftest.py
@@ -16,8 +16,8 @@
EXCLUDE_PATTERN = re.compile(
r'(?:'
- r'(__metadata__|backports|config|daemonize|diff|echo|exceptions|fixes|'
- r'logging|plural|time)|'
+ r'(__metadata__|backports|config|cosmetic_changes|daemonize|diff|echo|'
+ r'exceptions|fixes|logging|plural|time|titletranslate)|'
r'(comms|data|families|specialbots)/__init__|'
r'comms/eventstreams|'
r'data/(api/(__init__|_optionset)|memento|wikistats)|'
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index af94592..2d87ed6 100644
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -369,10 +369,8 @@
if not self.talkpage:
subpage = False
if self.template:
- loc = None
- with suppress(TypeError):
- _tmpl, loc = i18n.translate(self.site.code, moved_links)
- if loc is not None and loc in self.title:
+ loc = i18n.translate(self.site.code, moved_links)
+ if loc is not None and loc[1] in self.title:
subpage = True
# get interwiki
diff --git a/pywikibot/titletranslate.py b/pywikibot/titletranslate.py
index 1672004..1d381be 100644
--- a/pywikibot/titletranslate.py
+++ b/pywikibot/titletranslate.py
@@ -1,6 +1,6 @@
"""Title translate module."""
#
-# (C) Pywikibot team, 2003-2024
+# (C) Pywikibot team, 2003-2025
#
# Distributed under the terms of the MIT license.
#
@@ -46,7 +46,7 @@
for h in hints:
# argument may be given as -hint:xy where xy is a language code
- codes, _, newname = h.partition(':')
+ code, _, newname = h.partition(':')
if not newname:
# if given as -hint:xy or -hint:xy:, assume that there should
# be a page in language xy with the same title as the page
@@ -55,12 +55,12 @@
continue
newname = page.title(with_ns=False,
without_brackets=removebrackets)
- if codes.isdigit():
- codes = site.family.languages_by_size[:int(codes)]
- elif codes == 'all':
+ if code.isdigit():
+ codes = site.family.languages_by_size[:int(code)]
+ elif code == 'all':
codes = list(site.family.codes)
else:
- codes = site.family.language_groups.get(codes, codes.split(','))
+ codes = site.family.language_groups.get(code, code.split(','))
for newcode in codes:
if newcode in site.codes:
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1191816?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I6d2643d47fd4760d061eef8e1d13d4ea9c7418a7
Gerrit-Change-Number: 1191816
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]