Skip to content

Commit bda835c

Browse files
committed
Clean up print statements and other minor items flagged by @coderabbitai
1 parent 5119ccd commit bda835c

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

src/undate/converters/calendars/islamic/converter.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ def to_gregorian(self, year: int, month: int, day: int) -> tuple[int, int, int]:
7676
"""Convert a Hijri date, specified by year, month, and day,
7777
to the Gregorian equivalent date. Returns a tuple of year, month, day.
7878
"""
79-
print(
80-
f"islamic.to_gregorian(year={year}, month={month}, day={day}) = {islamic.to_gregorian(year, month, day)}"
81-
)
79+
# NOTE: this results in weird numbers for months when year gets sufficiently high
8280
return islamic.to_gregorian(year, month, day)
8381

8482
def parse(self, value: str) -> Union[Undate, UndateInterval]:

src/undate/undate.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def get_converter(calendar) -> BaseCalendarConverter:
3939
converter_cls = BaseDateConverter.available_converters()[
4040
calendar.value.title()
4141
]
42-
except KeyError:
43-
raise ValueError(f"Unknown calendar '{calendar}'")
42+
except KeyError as err:
43+
raise ValueError(f"Unknown calendar '{calendar}'") from err
4444
if not issubclass(converter_cls, BaseCalendarConverter):
4545
raise ValueError(
4646
f"Requested converter '{calendar.value.title()}' is not a CalendarConverter"
@@ -197,9 +197,6 @@ def calculate_earliest_latest(self, year, month, day):
197197
self.earliest = Date(
198198
*self.calendar_converter.to_gregorian(min_year, earliest_month, min_day)
199199
)
200-
print(
201-
f"initializing latest, year={max_year} month={latest_month} day={max_day}"
202-
)
203200
self.latest = Date(
204201
*self.calendar_converter.to_gregorian(max_year, latest_month, max_day)
205202
)
@@ -495,13 +492,12 @@ def possible_years(self) -> list[int] | range:
495492
# convert place to 1, 10, 100, 1000, etc.
496493
step = 10 ** (missing_digit_place - 1)
497494
return range(earliest_year, latest_year + 1, step)
498-
else: # year is fully unknown
499-
# returning range from min year to max year is not useful in any scenario!
500-
raise ValueError(
501-
"Possible years cannot be returned for completely unknown year"
502-
)
503495

504-
return [] # shouldn't get here, but mypy complains
496+
# otherwise, year is fully unknown
497+
# returning range from min year to max year is not useful in any scenario!
498+
raise ValueError(
499+
"Possible years cannot be returned for completely unknown year"
500+
)
505501

506502
@property
507503
def representative_years(self) -> list[int]:

tests/test_undate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ def test_possible_years(self):
407407
with pytest.raises(
408408
ValueError, match="cannot be returned for completely unknown year"
409409
):
410-
Undate("XXXX").possible_years
410+
assert Undate("XXXX").possible_years
411411

412412
def test_representative_years(self):
413413
# single year is returned as is

0 commit comments

Comments
 (0)