Revised to use a simpler way to run the class methods in the __get_desc method of the Period utility, to prevent confusion with SonarQube.

This commit is contained in:
依瑪貓 2023-03-08 14:31:36 +08:00
parent 7c3b8c8f44
commit a1627b7fbf

View File

@ -206,26 +206,25 @@ class Period:
:return: The period description. :return: The period description.
""" """
cls: t.Type[t.Self] = self.__class__
if self.start is None: if self.start is None:
if self.end is None: if self.end is None:
return gettext("for all time") return gettext("for all time")
else: else:
if self.end != _month_end(self.end): if self.end != _month_end(self.end):
return gettext("until %(end)s", return gettext("until %(end)s",
end=cls.__format_date(self.end)) end=self.__format_date(self.end))
if self.end.month != 12: if self.end.month != 12:
return gettext("until %(end)s", return gettext("until %(end)s",
end=cls.__format_month(self.end)) end=self.__format_month(self.end))
return gettext("until %(end)s", end=str(self.end.year)) return gettext("until %(end)s", end=str(self.end.year))
else: else:
if self.end is None: if self.end is None:
if self.start.day != 1: if self.start.day != 1:
return gettext("since %(start)s", return gettext("since %(start)s",
start=cls.__format_date(self.start)) start=self.__format_date(self.start))
if self.start.month != 1: if self.start.month != 1:
return gettext("since %(start)s", return gettext("since %(start)s",
start=cls.__format_month(self.start)) start=self.__format_month(self.start))
return gettext("since %(start)s", start=str(self.start.year)) return gettext("since %(start)s", start=str(self.start.year))
else: else:
try: try: