From 870488cee4e981d82dbad8e54fcdae77c7d286a5 Mon Sep 17 00:00:00 2001 From: Minku Koo Date: Wed, 18 Dec 2024 23:26:15 +0900 Subject: [PATCH] refactor: extract function-level constants to module-level - Ensures better adherence to PEP 8 naming conventions and improves code readability. --- .../formatting/difference_formatter.py | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/pendulum/formatting/difference_formatter.py b/src/pendulum/formatting/difference_formatter.py index 8233bf8a..81ba7fd3 100644 --- a/src/pendulum/formatting/difference_formatter.py +++ b/src/pendulum/formatting/difference_formatter.py @@ -8,6 +8,22 @@ if t.TYPE_CHECKING: from pendulum import Duration +DAYS_THRESHOLD_FOR_HALF_WEEK = 3 +DAYS_THRESHOLD_FOR_HALF_MONTH = 15 +MONTHS_THRESHOLD_FOR_HALF_YEAR = 6 + +HOURS_IN_NEARLY_A_DAY = 22 +DAYS_IN_NEARLY_A_MONTH = 27 +MONTHS_IN_NEARLY_A_YEAR = 11 + +DAYS_OF_WEEK = 7 +SECONDS_OF_MINUTE = 60 +FEW_SECONDS_MAX = 10 + +KEY_FUTURE = ".future" +KEY_PAST = ".past" +KEY_AFTER = ".after" +KEY_BEFORE = ".before" class DifferenceFormatter: """ @@ -32,22 +48,6 @@ def format( :param absolute: Whether it's an absolute difference or not :param locale: The locale to use """ - DAYS_THRESHOLD_FOR_HALF_WEEK = 3 - DAYS_THRESHOLD_FOR_HALF_MONTH = 15 - MONTHS_THRESHOLD_FOR_HALF_YEAR = 6 - - HOURS_IN_NEARLY_A_DAY = 22 - DAYS_IN_NEARLY_A_MONTH = 27 - MONTHS_IN_NEARLY_A_YEAR = 11 - - DAYS_OF_WEEK = 7 - SECONDS_OF_MINUTE = 60 - FEW_SECONDS_MAX = 10 - - KEY_FUTURE = ".future" - KEY_PAST = ".past" - KEY_AFTER = ".after" - KEY_BEFORE = ".before" locale = self._locale if locale is None else Locale.load(locale) if diff.years > 0: