Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions brutils/currency.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion brutils/data/enums/better_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 1 addition & 3 deletions brutils/data/enums/months.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
2 changes: 1 addition & 1 deletion brutils/legal_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions tests/test_date_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Loading