jenkins-bot submitted this change.
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(-)
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 change 699083. To unsubscribe, or for help writing mail filters, visit settings.