Skip to content

Commit 748b6e4

Browse files
jenkins-botGerrit Code Review
authored andcommitted
Merge "[cleanup] Drop pywikibot.BaseSite and pywikibotAPISite"
2 parents 2012f0c + 3f48d1d commit 748b6e4

File tree

5 files changed

+21
-16
lines changed

5 files changed

+21
-16
lines changed

pywikibot/__init__.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""The initialization file for the Pywikibot framework."""
22
#
3-
# (C) Pywikibot team, 2008-2023
3+
# (C) Pywikibot team, 2008-2024
44
#
55
# Distributed under the terms of the MIT license.
66
#
@@ -14,7 +14,7 @@
1414
from contextlib import suppress
1515
from queue import Queue
1616
from time import sleep as time_sleep
17-
from typing import Any, cast
17+
from typing import Any, TYPE_CHECKING, cast
1818
from urllib.parse import urlparse
1919
from warnings import warn
2020

@@ -67,11 +67,15 @@
6767
stdout,
6868
warning,
6969
)
70-
from pywikibot.site import APISite, BaseSite
70+
from pywikibot.site import BaseSite as _BaseSite
7171
from pywikibot.time import Timestamp
7272
from pywikibot.tools import normalize_username
7373

7474

75+
if TYPE_CHECKING:
76+
from pywikibot.site import APISite
77+
78+
7579
__all__ = (
7680
'__copyright__', '__description__', '__download_url__', '__license__',
7781
'__maintainer__', '__maintainer_email__', '__name__', '__url__',
@@ -127,11 +131,11 @@ def _code_fam_from_url(url: str, name: str | None = None
127131
return matched_sites[0]
128132

129133

130-
def Site(code: str | None = None, # noqa: 134
134+
def Site(code: str | None = None, # noqa: N802
131135
fam: str | Family | None = None,
132136
user: str | None = None, *,
133-
interface: str | BaseSite | None = None,
134-
url: str | None = None) -> BaseSite:
137+
interface: str | _BaseSite | None = None,
138+
url: str | None = None) -> _BaseSite:
135139
"""A factory method to obtain a Site object.
136140
137141
Site objects are cached and reused by this method.
@@ -242,7 +246,7 @@ def Site(code: str | None = None, # noqa: 134
242246
else:
243247
interface = getattr(tmp, interface)
244248

245-
if not issubclass(interface, BaseSite):
249+
if not issubclass(interface, _BaseSite):
246250
warning(f'Site called with interface={interface.__name__}')
247251

248252
user = normalize_username(user)

pywikibot/page/_wikibase.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* WikibaseEntity: base interface for Wikibase entities.
1010
"""
1111
#
12-
# (C) Pywikibot team, 2013-2023
12+
# (C) Pywikibot team, 2013-2024
1313
#
1414
# Distributed under the terms of the MIT license.
1515
#
@@ -65,7 +65,7 @@
6565
)
6666

6767
if TYPE_CHECKING:
68-
LANGUAGE_IDENTIFIER = str | pywikibot.APISite
68+
LANGUAGE_IDENTIFIER = str | pywikibot.site.APISite
6969
ALIASES_TYPE = dict[LANGUAGE_IDENTIFIER, list[str]]
7070
LANGUAGE_TYPE = dict[LANGUAGE_IDENTIFIER, str]
7171
SITELINK_TYPE = (

scripts/redirect.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
&params;
6767
"""
6868
#
69-
# (C) Pywikibot team, 2004-2023
69+
# (C) Pywikibot team, 2004-2024
7070
#
7171
# Distributed under the terms of the MIT license.
7272
#
@@ -408,11 +408,12 @@ def __init__(self, action, **kwargs) -> None:
408408
else:
409409
raise NotImplementedError(f'No valid action "{action}" found.')
410410

411-
def get_sd_template(self, site=None) -> str | None:
411+
def get_sd_template(
412+
self, site: pywikibot.site.BaseSite | None = None
413+
) -> str | None:
412414
"""Look for speedy deletion template and return it.
413415
414416
:param site: site for which the template has to be given
415-
:type site: pywikibot.BaseSite
416417
:return: A valid speedy deletion template.
417418
"""
418419
title = None

scripts/speedy_delete.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
.. note:: This script currently only works for the Wikipedia project.
2323
"""
2424
#
25-
# (C) Pywikibot team, 2007-2023
25+
# (C) Pywikibot team, 2007-2024
2626
#
2727
# Distributed under the terms of the MIT license.
2828
#
@@ -325,7 +325,7 @@ class SpeedyBot(SingleSiteBot, ExistingPageBot):
325325
def __init__(self, **kwargs) -> None:
326326
"""Initializer.
327327
328-
:keyword pywikibot.APISite site: the site to work on
328+
:keyword pywikibot.site.APISite site: the site to work on
329329
"""
330330
super().__init__(**kwargs)
331331
csd_cat = i18n.translate(self.site, self.csd_cat_title)

tests/category_bot_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
"""Tests for the category bot script."""
33
#
4-
# (C) Pywikibot team, 2015-2022
4+
# (C) Pywikibot team, 2015-2024
55
#
66
# Distributed under the terms of the MIT license.
77
#
@@ -12,7 +12,7 @@
1212
from unittest.mock import Mock, patch
1313

1414
import pywikibot
15-
from pywikibot import BaseSite
15+
from pywikibot.site import BaseSite
1616
from scripts.category import CategoryMoveRobot, CategoryPreprocess
1717
from tests.aspects import DefaultSiteTestCase, TestCase
1818

0 commit comments

Comments
 (0)