From 2f81e6861c148d673f76524747e05b47d8cf87cc Mon Sep 17 00:00:00 2001 From: Vishal Mishra Date: Wed, 29 Jul 2026 07:01:20 +0000 Subject: [PATCH 1/2] fix: small lint cleanups in currency, enums, and legal process Remove an unnecessary intermediate variable before return, simplify enum value collection, tighten month validation, and drop a redundant slice index. Co-authored-by: Cursor --- brutils/currency.py | 3 +-- brutils/data/enums/better_enum.py | 2 +- brutils/data/enums/months.py | 4 +--- brutils/legal_process.py | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/brutils/currency.py b/brutils/currency.py index 4e96bcc7..de76d3fd 100644 --- a/brutils/currency.py +++ b/brutils/currency.py @@ -25,12 +25,11 @@ def format_currency(value: float | int | str | Decimal) -> str | None: """ try: decimal_value = Decimal(value) - formatted_value = ( + return ( f"R$ {decimal_value:,.2f}".replace(",", "_") .replace(".", ",") .replace("_", ".") ) - return formatted_value except (InvalidOperation, TypeError, ValueError): return None diff --git a/brutils/data/enums/better_enum.py b/brutils/data/enums/better_enum.py index 35bda13c..27d4f40c 100644 --- a/brutils/data/enums/better_enum.py +++ b/brutils/data/enums/better_enum.py @@ -8,7 +8,7 @@ def names(cls): @property def values(cls): - return sorted(list(map(lambda x: x.value, cls._member_map_.values()))) + return sorted(x.value for x in cls._member_map_.values()) class BetterEnum(Enum, metaclass=__MetaEnum): diff --git a/brutils/data/enums/months.py b/brutils/data/enums/months.py index 5e22e56f..dc6d7de0 100644 --- a/brutils/data/enums/months.py +++ b/brutils/data/enums/months.py @@ -52,6 +52,4 @@ def is_valid_month(cls, month: int) -> bool: Returns: True if the month is valid, False otherwise. """ - return ( - True if month in set(month.value for month in MonthsEnum) else False - ) + return month in {month.value for month in MonthsEnum} diff --git a/brutils/legal_process.py b/brutils/legal_process.py index 53fdc006..ae2b2bbf 100644 --- a/brutils/legal_process.py +++ b/brutils/legal_process.py @@ -108,7 +108,7 @@ def is_valid(legal_process_id: str) -> bool: ) in process.get("id_foro") return ( - _checksum(int(clean_legal_process_id[0:7] + clean_legal_process_id[9:])) + _checksum(int(clean_legal_process_id[:7] + clean_legal_process_id[9:])) == DD ) and valid_process From 9f0d18410d009633c557611149b98b72d9c03b66 Mon Sep 17 00:00:00 2001 From: Vishal Mishra Date: Wed, 29 Jul 2026 07:17:19 +0000 Subject: [PATCH 2/2] test: cover MonthsEnum.is_valid_month for lint refactor Add unit tests so the simplified is_valid_month implementation stays fully covered for codecov patch checks. Co-authored-by: Cursor --- tests/test_date_utils.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_date_utils.py b/tests/test_date_utils.py index 136e59fc..2f4fb574 100644 --- a/tests/test_date_utils.py +++ b/tests/test_date_utils.py @@ -171,3 +171,9 @@ def testMonthEnum(self): for number_month, name_month in self.months_year: month = MonthsEnum(number_month) self.assertEqual(month.month_name, name_month) + + def test_is_valid_month(self): + for number_month, _ in self.months_year: + self.assertTrue(MonthsEnum.is_valid_month(number_month)) + self.assertFalse(MonthsEnum.is_valid_month(0)) + self.assertFalse(MonthsEnum.is_valid_month(13))