Skip to content

Commit

Permalink
Format all code with Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
rsheftel committed Dec 31, 2023
1 parent b6dee86 commit abe36a6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
6 changes: 3 additions & 3 deletions pandas_market_calendars/calendar_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ def _check_overlap(self, schedule):

if end_times.gt(schedule.start.shift(-1)).any():
raise ValueError(
f"The chosen frequency will lead to overlaps in the calculated index. "
f"Either choose a higher frequency or avoid setting force_close to None "
f"when setting closed to 'right', 'both' or None."
"The chosen frequency will lead to overlaps in the calculated index. "
"Either choose a higher frequency or avoid setting force_close to None "
"when setting closed to 'right', 'both' or None."
)

def _check_disappearing_session(self, schedule):
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@ exclude_also = [
]

ignore_errors = true

[tool.ruff.lint]
ignore = ["F403", "F405"]
4 changes: 2 additions & 2 deletions tests/test_exchange_calendar_cme_globex_energy_and_metals.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _test_has_late_opens(late_opens, start, end):
expected = cal.late_opens(schedule)
assert len(expected) == len(late_opens)
for ts in late_opens:
assert _test_verify_late_open_time(schedule, ts) == True
assert _test_verify_late_open_time(schedule, ts) is True


def _test_verify_early_close_time(schedule, timestamp):
Expand All @@ -81,7 +81,7 @@ def _test_has_early_closes(early_closes, start, end):
expected = cal.early_closes(schedule)
assert len(expected) == len(early_closes)
for ts in early_closes:
assert _test_verify_early_close_time(schedule, ts) == True
assert _test_verify_early_close_time(schedule, ts) is True


#########################################################################
Expand Down
10 changes: 5 additions & 5 deletions tests/test_nyse_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_custom_open_close():
assert sched.market_open.iat[0] == pd.Timestamp("2021-08-16 13:00:00+00:00")
assert sched.market_close.iat[0] == pd.Timestamp("2021-08-16 14:00:00+00:00")

assert not NYSEExchangeCalendar.regular_market_times is cal.regular_market_times
assert NYSEExchangeCalendar.regular_market_times is not cal.regular_market_times


@pytest.mark.parametrize(
Expand Down Expand Up @@ -129,16 +129,16 @@ def test_days_at_time_custom():
def test_valid_days():
cal = NYSEExchangeCalendar()

assert not cal.valid_days("1999-01-01", "2014-01-01") is None
assert cal.valid_days("1999-01-01", "2014-01-01") is not None
# used to raise an error because tz= None
assert not cal.valid_days("1999-01-01", "2014-01-01", tz=None) is None
assert cal.valid_days("1999-01-01", "2014-01-01", tz=None) is not None

assert (
not cal.special_dates("market_close", "1999-01-01", "2014-01-01", False) is None
cal.special_dates("market_close", "1999-01-01", "2014-01-01", False) is not None
)
# calls valid_days internally
assert (
not cal.special_dates("market_close", "1999-01-01", "2014-01-01", True) is None
cal.special_dates("market_close", "1999-01-01", "2014-01-01", True) is not None
)

start, end = "2000-01-01", "2000-01-30"
Expand Down
6 changes: 3 additions & 3 deletions tests/test_nyse_calendar_early_years.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def _test_has_late_opens(late_opens, start, end):
expected = nyse.late_opens(schedule)
assert len(expected) == len(late_opens)
for ts in late_opens:
assert _test_verify_late_open_time(schedule, ts) == True
assert _test_verify_late_open_time(schedule, ts) is True


def _test_verify_early_close_time(schedule, timestamp):
Expand All @@ -80,7 +80,7 @@ def _test_has_early_closes(early_closes, start, end):
expected = nyse.early_closes(schedule)
assert len(expected) == len(early_closes)
for ts in early_closes:
assert _test_verify_early_close_time(schedule, ts) == True
assert _test_verify_early_close_time(schedule, ts) is True


#########################################################################
Expand Down Expand Up @@ -4014,6 +4014,6 @@ def test_2025():
pd.Timestamp(
"2025-11-28 1:00PM", tz="America/New_York"
), # Day after Thanksgiving
pd.Timestamp("2025-12-24 1:00PM", tz="America/New_York"), # Christmas eve
pd.Timestamp("2025-12-24 1:00PM", tz="America/New_York"), # Christmas Eve
]
_test_has_early_closes(early_closes, start, end)
4 changes: 2 additions & 2 deletions tests/test_sifma_calendars.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _test_has_late_opens(cal, late_opens, start, end):
expected = cal.late_opens(schedule)
assert len(expected) == len(late_opens)
for ts in late_opens:
assert _test_verify_late_open_time(schedule, ts) == True
assert _test_verify_late_open_time(schedule, ts) is True


def _test_verify_early_close_time(schedule, timestamp):
Expand All @@ -67,7 +67,7 @@ def _test_has_early_closes(cal, early_closes, start, end):
expected = cal.early_closes(schedule)
assert len(expected) == len(early_closes)
for ts in early_closes:
assert _test_verify_early_close_time(schedule, ts) == True
assert _test_verify_early_close_time(schedule, ts) is True


#########################################################################
Expand Down

0 comments on commit abe36a6

Please sign in to comment.