jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/960556 )
Change subject: [mypy] solve some mypy issues
......................................................................
[mypy] solve some mypy issues
Change-Id: Ie014bdfa237974e2cb3f7ee39fa730292f79823d
---
M pywikibot/__init__.py
M pywikibot/backports.py
2 files changed, 18 insertions(+), 7 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index 3e14eb0..454c4bf 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -12,7 +12,7 @@
from contextlib import suppress
from queue import Queue
from time import sleep as time_sleep
-from typing import Any, Optional, Union
+from typing import Any, Optional, Union, cast
from urllib.parse import urlparse
from warnings import warn
@@ -224,6 +224,7 @@
if not isinstance(fam, Family):
fam = Family.load(fam)
+ fam = cast(Family, fam)
interface = interface or fam.interface(code)
# config.usernames is initialised with a defaultdict for each family name
@@ -237,6 +238,7 @@
if not isinstance(interface, type):
# If it isn't a class, assume it is a string
+ interface = cast(str, interface)
try:
tmp = __import__('pywikibot.site', fromlist=[interface])
except ImportError:
diff --git a/pywikibot/backports.py b/pywikibot/backports.py
index c1a7d05..f2a77ec 100644
--- a/pywikibot/backports.py
+++ b/pywikibot/backports.py
@@ -40,14 +40,14 @@
def __exit__(self, *excinfo: Any) -> None:
pass
else:
- from contextlib import nullcontext # type: ignore[misc]
+ from contextlib import nullcontext # type: ignore[assignment]
# queue
if PYTHON_VERSION < (3, 7):
from queue import Queue as SimpleQueue
else:
- from queue import SimpleQueue # type: ignore[misc]
+ from queue import SimpleQueue # type: ignore[assignment]
# typing
@@ -143,8 +143,8 @@
return string[:-len(suffix)]
return string
else:
- removeprefix = str.removeprefix # type: ignore[attr-defined]
- removesuffix = str.removesuffix # type: ignore[attr-defined]
+ removeprefix = str.removeprefix # type: ignore[assignment]
+ removesuffix = str.removesuffix # type: ignore[assignment]
# bpo-38200
@@ -163,7 +163,7 @@
next(b, None)
return zip(a, b)
else:
- from itertools import pairwise
+ from itertools import pairwise # type: ignore[no-redef]
# gh-98363
@@ -203,4 +203,4 @@
if group:
yield tuple(group)
else:
- from itertools import batched
+ from itertools import batched # type: ignore[no-redef]
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/960556
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ie014bdfa237974e2cb3f7ee39fa730292f79823d
Gerrit-Change-Number: 960556
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged