jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/699083 )
Change subject: Add type hints for APISite.get_tokens()
......................................................................
Add type hints for APISite.get_tokens()
It did cost me quite a while to find out why get_tokens("csrf") didn't
return anything. Answer: it needs to be get_tokens(["csrf"]). Hope the type
hints will help others.
Change-Id: Ifcf8e2aca9f47d1ec6e051ac03b9701af3ae6f54
---
M pywikibot/site/_apisite.py
1 file changed, 3 insertions(+), 3 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index f4dafbb..da2f734 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -19,6 +19,7 @@
import pywikibot
import pywikibot.family
+from pywikibot.backports import List
from pywikibot.comms.http import get_authentication
from pywikibot.data import api
from pywikibot.exceptions import (
@@ -1292,7 +1293,7 @@
return page._redirtarget
- def validate_tokens(self, types):
+ def validate_tokens(self, types: List[str]):
"""Validate if requested tokens are acceptable.
Valid tokens depend on mw version.
@@ -1315,7 +1316,7 @@
valid_types.append('csrf')
return valid_types
- def get_tokens(self, types, all: bool = False) -> dict:
+ def get_tokens(self, types: List[str], all: bool = False) -> dict:
"""Preload one or multiple tokens.
For MediaWiki version 1.23, only one token can be retrieved at once.
@@ -1336,7 +1337,6 @@
:param types: the types of token (e.g., "edit", "move", "delete");
see API documentation for full list of types
- :type types: iterable
:param all: load all available tokens, if None only if it can be done
in one request.
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/699083
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ifcf8e2aca9f47d1ec6e051ac03b9701af3ae6f54
Gerrit-Change-Number: 699083
Gerrit-PatchSet: 2
Gerrit-Owner: Holybiber <holybiber(a)4training.net>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/698632 )
Change subject: [IMPR] Default issue_deprecation_warning() to FutureWarning
......................................................................
[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(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
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 https://gerrit.wikimedia.org/r/c/pywikibot/core/+/698632
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I48f49c659b53337c551984e05cbd1350a3ba66a0
Gerrit-Change-Number: 698632
Gerrit-PatchSet: 3
Gerrit-Owner: Damian <atagar1(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/698635 )
Change subject: [bugfix] Drop is_ip_address('0.0.00.0') test assertion
......................................................................
[bugfix] Drop is_ip_address('0.0.00.0') test assertion
Strange. Previously this test passed but now it doesn't...
% python -m tests.tools_tests TestIsIpAddress
...
======================================================================
FAIL: test_valid_ipv4_addresses (__main__.TestIsIpAddress) (ip_address='0.0.00.0')
Check with valid IPv4 addresses.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/atagar/Desktop/pywikibot/tests/tools_tests.py", line 768, in
test_valid_ipv4_addresses
self.assertTrue(is_ip_address(address))
AssertionError: False is not true
We shouldn't assert that '0.0.00.0' is either valid *or* invalid since this can
evidently vary (though I don't know why). This method is just a pass-through
for python's ipaddress module so this is not a difference we can address within
our code.
Change-Id: I8a600315491863e013018fcc9e40d8a4e7d6a9d0
---
M tests/tools_tests.py
1 file changed, 0 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/tools_tests.py b/tests/tools_tests.py
index 0d5fd07..66a6bb5 100644
--- a/tests/tools_tests.py
+++ b/tests/tools_tests.py
@@ -756,7 +756,6 @@
"""Check with valid IPv4 addresses."""
valid_addresses = (
'0.0.0.0',
- '0.0.00.0',
'1.2.3.4',
'1.2.3.4',
'192.168.0.1',
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/698635
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I8a600315491863e013018fcc9e40d8a4e7d6a9d0
Gerrit-Change-Number: 698635
Gerrit-PatchSet: 3
Gerrit-Owner: Damian <atagar1(a)gmail.com>
Gerrit-Reviewer: DannyS712 <dannys712.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/698349 )
Change subject: [doc] Update documentation
......................................................................
[doc] Update documentation
* Update redirected URLs
Change-Id: I29f9ff8df3c8312f1d1b1475bc1c3ad4091b8274
---
M pywikibot/config.py
M pywikibot/page/__init__.py
2 files changed, 3 insertions(+), 3 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config.py b/pywikibot/config.py
index 7d50b6c..09729af 100644
--- a/pywikibot/config.py
+++ b/pywikibot/config.py
@@ -689,7 +689,7 @@
noisysleep = 3.0
# Defer bot edits during periods of database server lag. For details, see
-# https://www.mediawiki.org/wiki/Maxlag_parameter
+# https://www.mediawiki.org/wiki/Manual:Maxlag_parameter
# You can set this variable to a number of seconds, or to None (or 0) to
# disable this behavior. Higher values are more aggressive in seeking
# access to the wiki.
diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py
index 896bb55..3a81256 100644
--- a/pywikibot/page/__init__.py
+++ b/pywikibot/page/__init__.py
@@ -2263,7 +2263,7 @@
def _load_file_revisions(self, imageinfo):
for file_rev in imageinfo:
# filemissing in API response indicates most fields are missing
- # see https://gerrit.wikimedia.org/r/#/c/mediawiki/core/+/533482/
+ # see https://gerrit.wikimedia.org/r/c/mediawiki/core/+/533482/
if 'filemissing' in file_rev:
pywikibot.warning("File '{}' contains missing revisions"
.format(self.title()))
@@ -4532,7 +4532,7 @@
source = OrderedDict()
# Before #84516 Wikibase did not implement snaks-order.
- # https://gerrit.wikimedia.org/r/#/c/84516/
+ # https://gerrit.wikimedia.org/r/c/84516/
if 'snaks-order' in data:
prop_list = data['snaks-order']
else:
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/698349
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I29f9ff8df3c8312f1d1b1475bc1c3ad4091b8274
Gerrit-Change-Number: 698349
Gerrit-PatchSet: 3
Gerrit-Owner: Meno25 <meno25mail(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged