jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/721574 )
Change subject: [cleanup] Remove deprecated pywikibot.Error exceptions.py ......................................................................
[cleanup] Remove deprecated pywikibot.Error exceptions.py
Use pywikibot.exceptions.Error classes instead.
Bug: T280227 Change-Id: I01c946afa004c240be880fdc5b72c997d402bb74 --- M pywikibot/__init__.py M pywikibot/exceptions.py 2 files changed, 15 insertions(+), 91 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py index 926b280..a45eb48 100644 --- a/pywikibot/__init__.py +++ b/pywikibot/__init__.py @@ -6,12 +6,12 @@ # import atexit import datetime -import inspect import math import re import sys import threading import time + from contextlib import suppress from decimal import Decimal from queue import Queue @@ -47,10 +47,6 @@ ui, ) from pywikibot.diff import PatchManager -from pywikibot.exceptions import ( - DEPRECATED_EXCEPTIONS, - CoordinateGlobeUnknownError, -) from pywikibot.family import AutoFamily, Family from pywikibot.i18n import translate from pywikibot.logging import ( @@ -75,26 +71,16 @@
__all__ = ( '__copyright__', '__description__', '__download_url__', '__license__', - '__maintainer__', '__maintainer_email__', '__name__', - '__url__', '__version__', - 'Bot', 'calledModuleName', 'CaptchaError', 'CascadeLockedPage', - 'Category', 'CircularRedirect', 'Claim', 'Coordinate', - 'CoordinateGlobeUnknownException', 'critical', 'CurrentPageBot', 'debug', - 'EditConflict', 'error', 'Error', 'exception', 'FatalServerError', - 'FilePage', 'handle_args', 'html2unicode', 'input', 'input_choice', - 'input_yn', 'InterwikiRedirectPage', 'InvalidTitle', 'IsNotRedirectPage', - 'IsRedirectPage', 'ItemPage', 'Link', 'LockedNoPage', 'LockedPage', 'log', - 'MediaInfo', 'NoCreateError', 'NoMoveTarget', 'NoPage', 'NoUsername', - 'NoWikibaseEntity', 'OtherPageSaveError', 'output', 'Page', - 'PageCreatedConflict', 'PageDeletedConflict', 'PageRelatedError', - 'PageSaveRelatedError', 'PropertyPage', 'SectionError', 'Server414Error', - 'Server504Error', 'ServerError', 'showDiff', 'show_help', 'Site', - 'SiteDefinitionError', 'SiteLink', 'SpamblacklistError', 'stdout', - 'Timestamp', 'TitleblacklistError', 'translate', 'ui', 'unicode2html', - 'UnknownExtension', 'UnknownFamily', 'UnknownSite', 'UnsupportedPage', - 'UploadWarning', 'url2unicode', 'User', 'warning', 'WbGeoShape', - 'WbMonolingualText', 'WbQuantity', 'WbTabularData', 'WbTime', 'WbUnknown', - 'WikiBaseError', 'WikidataBot', + '__maintainer__', '__maintainer_email__', '__name__', '__url__', + '__version__', + 'Bot', 'calledModuleName', 'Category', 'Claim', 'Coordinate', 'critical', + 'CurrentPageBot', 'debug', 'error', 'exception', 'FilePage', 'handle_args', + 'html2unicode', 'input', 'input_choice', 'input_yn', 'ItemPage', 'Link', + 'log', 'MediaInfo', 'output', 'Page', 'PropertyPage', 'showDiff', + 'show_help', 'Site', 'SiteLink', 'stdout', 'Timestamp', 'translate', 'ui', + 'unicode2html', 'UploadWarning', 'url2unicode', 'User', 'warning', + 'WbGeoShape', 'WbMonolingualText', 'WbQuantity', 'WbTabularData', 'WbTime', + 'WbUnknown', 'WikidataBot', )
# argvu is set by pywikibot.bot when it's imported @@ -271,7 +257,7 @@ """Return the entity uri of the globe.""" if not self._entity: if self.globe not in self.site.globes(): - raise CoordinateGlobeUnknownError( + raise exceptions.CoordinateGlobeUnknownError( '{} is not supported in Wikibase yet.' .format(self.globe)) return self.site.globes()[self.globe] @@ -1398,29 +1384,3 @@ wrapper.add_deprecated_attr( 'unicode2html', replacement_name='pywikibot.tools.chars.string2html', since='6.2.0') - -# This module aliases many (but not all) pywikibot.exception classes and one -# from pywikibot.data.api. Use of these aliases is deprecated. When removed -# we can drop them from both our import and __all__ listing. - -EXCEPTION_CLASSES = { - n for n, _ in inspect.getmembers(exceptions, inspect.isclass) -} - -EXCEPTION_CLASSES.add('UploadWarning') -EXCEPTION_CLASSES.update(DEPRECATED_EXCEPTIONS.keys()) - -for name in __all__: - if name in EXCEPTION_CLASSES: - if name in DEPRECATED_EXCEPTIONS: - replacement = DEPRECATED_EXCEPTIONS[name] - elif name == 'UploadWarning': - replacement = 'UploadError' - else: - replacement = name - - wrapper.add_deprecated_attr( - name, - replacement_name='pywikibot.exceptions.{}'.format(replacement), - since='20210424' - ) diff --git a/pywikibot/exceptions.py b/pywikibot/exceptions.py index 13e0eee..f844f98 100644 --- a/pywikibot/exceptions.py +++ b/pywikibot/exceptions.py @@ -153,7 +153,8 @@ - ArgumentDeprecationWarning: command line argument problems - FamilyMaintenanceWarning: missing information in family definition
-*Changed in version 6.0:* exceptions were renamed and are ending with "Error". +.. versionchanged:: 6.0 + exceptions were renamed and are ending with "Error". """ # # (C) Pywikibot team, 2008-2021 @@ -161,11 +162,10 @@ # Distributed under the terms of the MIT license. # import re -import sys from typing import Any, Optional, Union
import pywikibot -from pywikibot.tools import ModuleDeprecationWrapper, issue_deprecation_warning +from pywikibot.tools import issue_deprecation_warning from pywikibot.tools._deprecate import _NotImplementedWarning
@@ -680,39 +680,3 @@ class MaxlagTimeoutError(TimeoutError):
"""Request failed with a maxlag timeout error.""" - - -DEPRECATED_EXCEPTIONS = { - 'NoUsername': 'NoUsernameError', - 'NoPage': 'NoPageError', - 'UnsupportedPage': 'UnsupportedPageError', - 'NoMoveTarget': 'NoMoveTargetError', - 'InconsistentTitleReceived': 'InconsistentTitleError', - 'UnknownSite': 'UnknownSiteError', - 'UnknownFamily': 'UnknownFamilyError', - 'UnknownExtension': 'UnknownExtensionError', - 'IsRedirectPage': 'IsRedirectPageError', - 'IsNotRedirectPage': 'IsNotRedirectPageError', - 'CircularRedirect': 'CircularRedirectError', - 'InterwikiRedirectPage': 'InterwikiRedirectPageError', - 'InvalidTitle': 'InvalidTitleError', - 'LockedPage': 'LockedPageError', - 'LockedNoPage': 'LockedNoPageError', - 'CascadeLockedPage': 'CascadeLockedPageError', - 'EditConflict': 'EditConflictError', - 'PageDeletedConflict': 'PageDeletedConflictError', - 'PageCreatedConflict': 'PageCreatedConflictError', - 'ArticleExistsConflict': 'ArticleExistsConflictError', - 'AutoblockUser': 'AutoblockUserError', - 'NoWikibaseEntity': 'NoWikibaseEntityError', - 'CoordinateGlobeUnknownException': 'CoordinateGlobeUnknownError', - 'EntityTypeUnknownException': 'EntityTypeUnknownError', -} - -wrapper = ModuleDeprecationWrapper(__name__) -module = sys.modules[__name__] - -for old_name, new_name in DEPRECATED_EXCEPTIONS.items(): - setattr(module, old_name, getattr(module, new_name)) - wrapper.add_deprecated_attr(old_name, replacement_name=new_name, - since='20210423')