summaryrefslogtreecommitdiffstats
path: root/pendulum/mixins/default.py
diff options
context:
space:
mode:
Diffstat (limited to 'pendulum/mixins/default.py')
-rw-r--r--pendulum/mixins/default.py79
1 files changed, 36 insertions, 43 deletions
diff --git a/pendulum/mixins/default.py b/pendulum/mixins/default.py
index bfb5912..59f985e 100644
--- a/pendulum/mixins/default.py
+++ b/pendulum/mixins/default.py
@@ -1,43 +1,36 @@
-from ..formatting import Formatter
-
-
-_formatter = Formatter()
-
-
-class FormattableMixin(object):
-
- _formatter = _formatter
-
- def format(self, fmt, locale=None):
- """
- Formats the instance using the given format.
-
- :param fmt: The format to use
- :type fmt: str
-
- :param locale: The locale to use
- :type locale: str or None
-
- :rtype: str
- """
- return self._formatter.format(self, fmt, locale)
-
- def for_json(self):
- """
- Methods for automatic json serialization by simplejson
-
- :rtype: str
- """
- return str(self)
-
- def __format__(self, format_spec):
- if len(format_spec) > 0:
- if "%" in format_spec:
- return self.strftime(format_spec)
-
- return self.format(format_spec)
-
- return str(self)
-
- def __str__(self):
- return self.isoformat()
+from __future__ import annotations
+
+from pendulum.formatting import Formatter
+
+_formatter = Formatter()
+
+
+class FormattableMixin:
+ _formatter: Formatter = _formatter
+
+ def format(self, fmt: str, locale: str | None = None) -> str:
+ """
+ Formats the instance using the given format.
+
+ :param fmt: The format to use
+ :param locale: The locale to use
+ """
+ return self._formatter.format(self, fmt, locale)
+
+ def for_json(self) -> str:
+ """
+ Methods for automatic json serialization by simplejson.
+ """
+ return str(self)
+
+ def __format__(self, format_spec: str) -> str:
+ if len(format_spec) > 0:
+ if "%" in format_spec:
+ return self.strftime(format_spec)
+
+ return self.format(format_spec)
+
+ return str(self)
+
+ def __str__(self) -> str:
+ return self.isoformat()