jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/854871 )
Change subject: [IMPR] raise TypeError instead of ValueError in Timestamp.set_timestamp ...................................................................... [IMPR] raise TypeError instead of ValueError in Timestamp.set_timestamp raise TypeError instead of ValueError if ts parameter is a wrong type according to https://docs.python.org/3/library/exceptions.html#TypeError Change-Id: I486c6fec012f0d57b52428e5732978325c9be706 --- M pywikibot/time.py 1 file changed, 5 insertions(+), 3 deletions(-) Approvals: Mpaa: Looks good to me, approved jenkins-bot: Verified diff --git a/pywikibot/time.py b/pywikibot/time.py index cf90546..63bca0d 100644 --- a/pywikibot/time.py +++ b/pywikibot/time.py @@ -80,10 +80,12 @@ - POSIX format: seconds from Unix epoch S{1,13}[.ffffff]] .. versionadded:: 7.5 + .. versionchanged:: 8.0 + raises *TypeError* instead of *ValueError*. :param ts: Timestamp, datetime.datetime or str :return: Timestamp object - :raises ValueError: conversion failed + :raises TypeError: conversion failed """ if isinstance(ts, cls): return ts @@ -91,8 +93,8 @@ return cls._from_datetime(ts) if isinstance(ts, str): return cls._from_string(ts) - raise ValueError('Unsupported "ts" type, got "{}" ({})' - .format(ts, type(ts).__name__)) + raise TypeError( + f'Unsupported "ts" type, got "{ts}" ({type(ts).__name__})') @staticmethod def _from_datetime(dt: datetime.datetime) -> 'Timestamp': -- To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/854871 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: I486c6fec012f0d57b52428e5732978325c9be706 Gerrit-Change-Number: 854871 Gerrit-PatchSet: 1 Gerrit-Owner: Xqt <[email protected]> Gerrit-Reviewer: Mpaa <[email protected]> Gerrit-Reviewer: jenkins-bot Gerrit-MessageType: merged
_______________________________________________ Pywikibot-commits mailing list -- [email protected] To unsubscribe send an email to [email protected]
