jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/571535 )
Change subject: [cleanup] Throw a FutureWarning if compat module is used ......................................................................
[cleanup] Throw a FutureWarning if compat module is used
- use FutureWarning instead of DeprecationWarning for this module - update doc - update HISTORY.rst
query.py: - replace multiple deprecate_arg decorators with deprecated_args - remove last 'back_response' parameter - remove 'back_response' result after 8 years which was never supported
Bug: T183085 Change-Id: Ie51b5d9a120925048a4ec3c2c3d0a987b13e63b2 --- M HISTORY.rst M pywikibot/compat/__init__.py M pywikibot/compat/catlib.py M pywikibot/compat/query.py M pywikibot/compat/userlib.py M tox.ini 6 files changed, 31 insertions(+), 34 deletions(-)
Approvals: Dvorapa: Looks good to me, approved jenkins-bot: Verified
diff --git a/HISTORY.rst b/HISTORY.rst index 3bcdd32..5898f37 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,6 +4,7 @@ Current release ---------------
+* compat module is deprecated for 5 years and will be removed with next release (T183085) * ipaddress module is required for Python 2 (T243171) * tools.ip will be dropped in favour of tools.is_IP (T243171) * tools.ip_regexp is deprecatd for 5 years and will be removed with next release diff --git a/pywikibot/compat/__init__.py b/pywikibot/compat/__init__.py index 1f9845b..eaf5879 100644 --- a/pywikibot/compat/__init__.py +++ b/pywikibot/compat/__init__.py @@ -1,2 +1,6 @@ # -*- coding: utf-8 -*- -"""Package to provide compatibility with compat scripts.""" +""" +WARNING: THIS MODULE EXISTS SOLELY TO PROVIDE COMPAT BACKWARDS-COMPATIBILITY. + +IT IS DEPRECATED. DO NOT USE IT. +""" diff --git a/pywikibot/compat/catlib.py b/pywikibot/compat/catlib.py index 1214f95..b7fb4e9 100644 --- a/pywikibot/compat/catlib.py +++ b/pywikibot/compat/catlib.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- """ -WARNING: THIS MODULE EXISTS SOLELY TO PROVIDE BACKWARDS-COMPATIBILITY. +WARNING: THIS MODULE EXISTS SOLELY TO PROVIDE COMPAT BACKWARDS-COMPATIBILITY.
-Do not use in new scripts; use the source to find the appropriate -function/method instead. +IT IS DEPRECATED. DO NOT USE IT.
+Do not use this module anymore; use pywikibot.Category class +or Page.change_category method instead. """ # -# (C) Pywikibot team, 2008-2018 +# (C) Pywikibot team, 2008-2020 # # Distributed under the terms of the MIT license. # @@ -28,7 +29,7 @@ wrapper = ModuleDeprecationWrapper(__name__) wrapper._add_deprecated_attr('Category', replacement_name='pywikibot.Category', - since='20141209') + since='20141209', future_warning=True) wrapper._add_deprecated_attr('change_category', replacement_name='Page.change_category', - since='20141209') + since='20141209', future_warning=True) diff --git a/pywikibot/compat/query.py b/pywikibot/compat/query.py index 830f87a..967db30 100644 --- a/pywikibot/compat/query.py +++ b/pywikibot/compat/query.py @@ -1,30 +1,28 @@ # -*- coding: utf-8 -*- """ -WARNING: THIS MODULE EXISTS SOLELY TO PROVIDE BACKWARDS-COMPATIBILITY. +WARNING: THIS MODULE EXISTS SOLELY TO PROVIDE COMPAT BACKWARDS-COMPATIBILITY.
-Do not use in new scripts; use the source to find the appropriate -function/method instead. +IT IS DEPRECATED. DO NOT USE IT.
+Do not use this module anymore; use pywikibot.data.api.Request +or Page/APISite highlevel methods instead. """ # -# (C) Pywikibot team, 2008-2019 +# (C) Pywikibot team, 2008-2020 # # Distributed under the terms of the MIT license. # from __future__ import absolute_import, division, unicode_literals
-import pywikibot from pywikibot.data import api -from pywikibot.tools import deprecated, deprecate_arg - -import io +from pywikibot.tools import deprecated, deprecated_args, remove_last_args
-@deprecated('pywikibot.data.api.Request', since='20120603') -@deprecate_arg('useAPI', None) -@deprecate_arg('retryCount', None) -@deprecate_arg('encodeTitle', None) -def GetData(request, site=None, back_response=False): +@deprecated('pywikibot.data.api.Request', since='20120603', + future_warning=True) +@deprecated_args(useAPI=None, retryCount=None, encodeTitle=None) +@remove_last_args(['back_response']) +def GetData(request, site=None): """ Query the server with the given request dict.
@@ -34,15 +32,7 @@ request['site'] = site
req = api.Request(**request) - result = req.submit() - - if back_response: - pywikibot.warning('back_response is no longer supported; an empty ' - 'response object will be returned') - res_dummy = io.StringIO() - res_dummy.__dict__.update({'code': 0, 'msg': ''}) - return res_dummy, result - return result + return req.submit()
__all__ = (GetData, ) diff --git a/pywikibot/compat/userlib.py b/pywikibot/compat/userlib.py index 1c34231..c664d3c 100644 --- a/pywikibot/compat/userlib.py +++ b/pywikibot/compat/userlib.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- """ -WARNING: THIS MODULE EXISTS SOLELY TO PROVIDE BACKWARDS-COMPATIBILITY. +WARNING: THIS MODULE EXISTS SOLELY TO PROVIDE COMPAT BACKWARDS-COMPATIBILITY.
-Do not use in new scripts; use the source to find the appropriate -function/method instead. +IT IS DEPRECATED. DO NOT USE IT.
+Do not use this module anymore; use pywikibot.User instead. """ # -# (C) Pywikibot team, 2008-2018 +# (C) Pywikibot team, 2008-2020 # # Distributed under the terms of the MIT license. # @@ -21,4 +21,4 @@ wrapper = ModuleDeprecationWrapper(__name__) wrapper._add_deprecated_attr('User', replacement_name='pywikibot.User', - since='20141209') + since='20141209', future_warning=True) diff --git a/tox.ini b/tox.ini index 8a31790..e11c674 100644 --- a/tox.ini +++ b/tox.ini @@ -122,6 +122,7 @@ pywikibot/_wbtypes.py: N802 pywikibot/backports.py: N802 pywikibot/bot.py: N802, N815, N816 + pywikibot/compat/__init__.py: FI10, FI11, FI14 pywikibot/compat/catlib.py : N803 pywikibot/compat/query.py: N802 pywikibot/config2.py: N816
pywikibot-commits@lists.wikimedia.org