Skip to content

Commit

Permalink
Merge "[cleanup] Drop pywikibot.BaseSite and pywikibotAPISite"
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Jan 30, 2024
2 parents 2012f0c + 3f48d1d commit 748b6e4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
18 changes: 11 additions & 7 deletions pywikibot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""The initialization file for the Pywikibot framework."""
#
# (C) Pywikibot team, 2008-2023
# (C) Pywikibot team, 2008-2024
#
# Distributed under the terms of the MIT license.
#
Expand All @@ -14,7 +14,7 @@
from contextlib import suppress
from queue import Queue
from time import sleep as time_sleep
from typing import Any, cast
from typing import Any, TYPE_CHECKING, cast
from urllib.parse import urlparse
from warnings import warn

Expand Down Expand Up @@ -67,11 +67,15 @@
stdout,
warning,
)
from pywikibot.site import APISite, BaseSite
from pywikibot.site import BaseSite as _BaseSite
from pywikibot.time import Timestamp
from pywikibot.tools import normalize_username


if TYPE_CHECKING:
from pywikibot.site import APISite


__all__ = (
'__copyright__', '__description__', '__download_url__', '__license__',
'__maintainer__', '__maintainer_email__', '__name__', '__url__',
Expand Down Expand Up @@ -127,11 +131,11 @@ def _code_fam_from_url(url: str, name: str | None = None
return matched_sites[0]


def Site(code: str | None = None, # noqa: 134
def Site(code: str | None = None, # noqa: N802
fam: str | Family | None = None,
user: str | None = None, *,
interface: str | BaseSite | None = None,
url: str | None = None) -> BaseSite:
interface: str | _BaseSite | None = None,
url: str | None = None) -> _BaseSite:
"""A factory method to obtain a Site object.
Site objects are cached and reused by this method.
Expand Down Expand Up @@ -242,7 +246,7 @@ def Site(code: str | None = None, # noqa: 134
else:
interface = getattr(tmp, interface)

if not issubclass(interface, BaseSite):
if not issubclass(interface, _BaseSite):
warning(f'Site called with interface={interface.__name__}')

user = normalize_username(user)
Expand Down
4 changes: 2 additions & 2 deletions pywikibot/page/_wikibase.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* WikibaseEntity: base interface for Wikibase entities.
"""
#
# (C) Pywikibot team, 2013-2023
# (C) Pywikibot team, 2013-2024
#
# Distributed under the terms of the MIT license.
#
Expand Down Expand Up @@ -65,7 +65,7 @@
)

if TYPE_CHECKING:
LANGUAGE_IDENTIFIER = str | pywikibot.APISite
LANGUAGE_IDENTIFIER = str | pywikibot.site.APISite
ALIASES_TYPE = dict[LANGUAGE_IDENTIFIER, list[str]]
LANGUAGE_TYPE = dict[LANGUAGE_IDENTIFIER, str]
SITELINK_TYPE = (
Expand Down
7 changes: 4 additions & 3 deletions scripts/redirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
&params;
"""
#
# (C) Pywikibot team, 2004-2023
# (C) Pywikibot team, 2004-2024
#
# Distributed under the terms of the MIT license.
#
Expand Down Expand Up @@ -408,11 +408,12 @@ def __init__(self, action, **kwargs) -> None:
else:
raise NotImplementedError(f'No valid action "{action}" found.')

def get_sd_template(self, site=None) -> str | None:
def get_sd_template(
self, site: pywikibot.site.BaseSite | None = None
) -> str | None:
"""Look for speedy deletion template and return it.
:param site: site for which the template has to be given
:type site: pywikibot.BaseSite
:return: A valid speedy deletion template.
"""
title = None
Expand Down
4 changes: 2 additions & 2 deletions scripts/speedy_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
.. note:: This script currently only works for the Wikipedia project.
"""
#
# (C) Pywikibot team, 2007-2023
# (C) Pywikibot team, 2007-2024
#
# Distributed under the terms of the MIT license.
#
Expand Down Expand Up @@ -325,7 +325,7 @@ class SpeedyBot(SingleSiteBot, ExistingPageBot):
def __init__(self, **kwargs) -> None:
"""Initializer.
:keyword pywikibot.APISite site: the site to work on
:keyword pywikibot.site.APISite site: the site to work on
"""
super().__init__(**kwargs)
csd_cat = i18n.translate(self.site, self.csd_cat_title)
Expand Down
4 changes: 2 additions & 2 deletions tests/category_bot_tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""Tests for the category bot script."""
#
# (C) Pywikibot team, 2015-2022
# (C) Pywikibot team, 2015-2024
#
# Distributed under the terms of the MIT license.
#
Expand All @@ -12,7 +12,7 @@
from unittest.mock import Mock, patch

import pywikibot
from pywikibot import BaseSite
from pywikibot.site import BaseSite
from scripts.category import CategoryMoveRobot, CategoryPreprocess
from tests.aspects import DefaultSiteTestCase, TestCase

Expand Down

0 comments on commit 748b6e4

Please sign in to comment.