jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1001357?usp=email )
Change subject: [cleanup] use type annotation for singledispatch ......................................................................
[cleanup] use type annotation for singledispatch
The register() attribute supports using type annotations with Python 3.7. Ignore it for some function, otherwise Union, Tuple, and List must be imported from typing.
Bug: T347026 Change-Id: I543098278eeb9c4af187b17a4f18dfb12056a78b --- M pywikibot/date.py 1 file changed, 17 insertions(+), 3 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/date.py b/pywikibot/date.py index 4a85afc..09d7caf 100644 --- a/pywikibot/date.py +++ b/pywikibot/date.py @@ -240,7 +240,7 @@ return lst[value - 1]
-@slh.register(str) +@slh.register def _(value: str, lst: Sequence[str]) -> int: return lst.index(value) + 1
@@ -251,7 +251,7 @@ return dh_constVal(value, 0, match)
-@dh_singVal.register(str) +@dh_singVal.register def _(value: str, match: str) -> int: return dh_constVal(value, 0, match) # type: ignore[return-value]
@@ -268,7 +268,7 @@ raise ValueError(f'unknown value {value}')
-@dh_constVal.register(str) +@dh_constVal.register def _(value: str, ind: int, match: str) -> int: if value == match: return ind
pywikibot-commits@lists.wikimedia.org