jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[IMPR] Default issue_deprecation_warning() to FutureWarning

Oops! Commit fd38f5d09 should've standardized deprecations on FutureWarnings
but I missed issue_deprecation_warning(). It uses a different argument
('warning_class=FutureWarning' rather than 'future_warning=True').

Defaulting this to emit FutureWarnings like the rest of our deprecation
methods.

Bug: T281202
Change-Id: I48f49c659b53337c551984e05cbd1350a3ba66a0
---
M pywikibot/bot_choice.py
M pywikibot/comms/http.py
M pywikibot/cosmetic_changes.py
M pywikibot/exceptions.py
M pywikibot/page/__init__.py
M pywikibot/site/_datasite.py
M pywikibot/site/_generators.py
M pywikibot/tools/__init__.py
8 files changed, 10 insertions(+), 22 deletions(-)

diff --git a/pywikibot/bot_choice.py b/pywikibot/bot_choice.py
index af6a87a..f3a0d34 100755
--- a/pywikibot/bot_choice.py
+++ b/pywikibot/bot_choice.py
@@ -183,7 +183,6 @@
if not hasattr(self._outputter, 'out'):
issue_deprecation_warning('{} without "out" property'
.format(self.__class__.__name__),
- warning_class=FutureWarning,
since='6.2.0')
return self._outputter.output()
return self._outputter.out
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py
index d0ddea1..695923b 100644
--- a/pywikibot/comms/http.py
+++ b/pywikibot/comms/http.py
@@ -249,7 +249,6 @@
if old_validation is not None:
issue_deprecation_warning('disable_ssl_certificate_validation',
instead='verify',
- warning_class=FutureWarning,
since='20201220')
kwargs.update(verify=not old_validation)

@@ -407,7 +406,6 @@
if old_validation is not None:
issue_deprecation_warning('disable_ssl_certificate_validation',
instead='verify',
- warning_class=FutureWarning,
since='20201220')
kwargs.update(verify=not old_validation)

diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index ab70b7d..11a71e9 100755
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -251,7 +251,6 @@
issue_deprecation_warning(
'site parameter of CosmeticChangesToolkit',
'a pywikibot.Page object as first parameter',
- warning_class=FutureWarning,
since='20201102')
else:
if namespace is not None or pageTitle is not None:
diff --git a/pywikibot/exceptions.py b/pywikibot/exceptions.py
index adf7f5a..0ff4b3a 100644
--- a/pywikibot/exceptions.py
+++ b/pywikibot/exceptions.py
@@ -300,8 +300,7 @@
elif re.search(r'%\(\w+\)s', self.message):
issue_deprecation_warning("'%' style messages are deprecated, "
'please use str.format() style instead',
- since='20210504',
- warning_class=FutureWarning)
+ since='20210504')
msg = self.message % self.__dict__
elif '%s' in self.message:
msg = self.message % page
diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py
index ddbd03d..6502954 100644
--- a/pywikibot/page/__init__.py
+++ b/pywikibot/page/__init__.py
@@ -5766,7 +5766,6 @@
'Passing BaseSite object to encodings parameter',
'BaseSite.endcodings()',
depth=1,
- warning_class=FutureWarning,
since='6.2.0'
)

diff --git a/pywikibot/site/_datasite.py b/pywikibot/site/_datasite.py
index 56dd857..71ed462 100644
--- a/pywikibot/site/_datasite.py
+++ b/pywikibot/site/_datasite.py
@@ -145,7 +145,6 @@
"""Check that claim.on_item is set and matches baserevid if used."""
if not claim.on_item:
issue_deprecation_warning('claim without on_item set', depth=3,
- warning_class=FutureWarning,
since='20160309')
if not baserevid:
warn('Neither claim.on_item nor baserevid provided',
diff --git a/pywikibot/site/_generators.py b/pywikibot/site/_generators.py
index 701f67b..16d38fe 100644
--- a/pywikibot/site/_generators.py
+++ b/pywikibot/site/_generators.py
@@ -1365,7 +1365,6 @@
if where == 'titles':
issue_deprecation_warning("where='titles'",
"where='title'",
- warning_class=FutureWarning,
since='20160224')
where = 'title'
if not namespaces and namespaces != 0:
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index 0a36a6b..a941084 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -470,9 +470,7 @@

def __getattr__(self, attr):
"""Issue deprecation warning."""
- issue_deprecation_warning(
- self._name, self._instead, warning_class=FutureWarning,
- since=self._since)
+ issue_deprecation_warning(self._name, self._instead, since=self._since)
return super().__getattr__(attr)


@@ -1104,9 +1102,7 @@
def __call__(self):
"""Do nothing and just return itself."""
issue_deprecation_warning('Referencing this attribute like a function',
- 'it directly',
- warning_class=FutureWarning,
- since='20210420')
+ 'it directly', since='20210420')

return self

@@ -1443,7 +1439,7 @@
:param depth: depth + 1 will be used as stacklevel for the warnings
:type depth: int
:param warning_class: a warning class (category) to be used, defaults to
- DeprecationWarning
+ FutureWarning
:type warning_class: type
:param since: a timestamp string of the date when the method was
deprecated (form 'YYYYMMDD') or a version string.
@@ -1451,7 +1447,7 @@
"""
msg = _build_msg_string(instead, since)
if warning_class is None:
- warning_class = (DeprecationWarning
+ warning_class = (FutureWarning
if instead else _NotImplementedWarning)
warn(msg.format(name, instead), warning_class, depth + 1)

@@ -1466,7 +1462,7 @@
deprecated (form 'YYYYMMDD') or a version string.
:type since: str
:keyword future_warning: if True a FutureWarning will be thrown,
- otherwise it defaults to DeprecationWarning
+ otherwise it provides a DeprecationWarning
:type future_warning: bool
"""
def decorator(obj):
@@ -1489,7 +1485,7 @@
depth = get_wrapper_depth(wrapper) + 1
issue_deprecation_warning(
name, instead, depth, since=since,
- warning_class=FutureWarning if future_warning else None)
+ warning_class=None if future_warning else DeprecationWarning)
return obj(*args, **kwargs)

def add_docstring(wrapper):
@@ -1763,7 +1759,7 @@
:param since: a timestamp string of the date when the method was
deprecated (form 'YYYYMMDD') or a version string.
:param future_warning: if True a FutureWarning will be thrown,
- otherwise it defaults to DeprecationWarning
+ otherwise it provides a DeprecationWarning
:type future_warning: bool
:return: A new function which adds a warning prior to each execution.
:rtype: callable
@@ -1771,7 +1767,7 @@
def call(*a, **kw):
issue_deprecation_warning(
old_name, new_name, since=since,
- warning_class=FutureWarning if future_warning else None)
+ warning_class=None if future_warning else DeprecationWarning)
return target(*a, **kw)
if target_module is None:
target_module = target.__module__
@@ -1840,7 +1836,7 @@
:param since: a timestamp string of the date when the method was
deprecated (form 'YYYYMMDD') or a version string.
:param future_warning: if True a FutureWarning will be thrown,
- otherwise it defaults to DeprecationWarning
+ otherwise it provides a DeprecationWarning
"""
if '.' in name:
raise ValueError('Deprecated name "{}" may not contain '

To view, visit change 698632. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I48f49c659b53337c551984e05cbd1350a3ba66a0
Gerrit-Change-Number: 698632
Gerrit-PatchSet: 3
Gerrit-Owner: Damian <atagar1@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged