jenkins-bot submitted this change.

View Change


Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[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(-)

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

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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I543098278eeb9c4af187b17a4f18dfb12056a78b
Gerrit-Change-Number: 1001357
Gerrit-PatchSet: 6
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged