From 5f62951e0e4a794e07bfcd6e3fd8c424b9b42dfe Mon Sep 17 00:00:00 2001 From: Stefan Jansen Date: Thu, 14 Mar 2024 11:50:28 -0400 Subject: [PATCH] fixed flake8 lint errors due to version upgrade --- .pre-commit-config.yaml | 2 +- src/zipline/currency.py | 2 +- src/zipline/finance/trading.py | 5 ++--- src/zipline/testing/core.py | 4 ++-- src/zipline/testing/fixtures.py | 1 - src/zipline/testing/predicates.py | 2 +- src/zipline/utils/factory.py | 4 ++-- 7 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b7f9c1da18..37f5d73add 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: hooks: - id: black additional_dependencies: ['click==8.0.4'] - language_version: python3.9 + language_version: python3.11 - repo: https://github.com/PyCQA/flake8 rev: '6.0.0' hooks: diff --git a/src/zipline/currency.py b/src/zipline/currency.py index 69ccfd3df4..813297373a 100644 --- a/src/zipline/currency.py +++ b/src/zipline/currency.py @@ -61,7 +61,7 @@ def name(self): return self._name def __eq__(self, other): - if type(self) != type(other): + if type(self) is not type(other): return NotImplemented return self.code == other.code diff --git a/src/zipline/finance/trading.py b/src/zipline/finance/trading.py index d29ceb2d99..b67a7b4f48 100644 --- a/src/zipline/finance/trading.py +++ b/src/zipline/finance/trading.py @@ -35,9 +35,8 @@ def __init__( data_frequency="daily", arena="backtest", ): - - assert type(start_session) == pd.Timestamp - assert type(end_session) == pd.Timestamp + assert type(start_session) is pd.Timestamp + assert type(end_session) is pd.Timestamp assert trading_calendar is not None, "Must pass in trading calendar!" assert start_session <= end_session, "Period start falls after period end." diff --git a/src/zipline/testing/core.py b/src/zipline/testing/core.py index 8fb250cf29..9bff4cc751 100644 --- a/src/zipline/testing/core.py +++ b/src/zipline/testing/core.py @@ -293,7 +293,7 @@ def check_allclose(actual, desired, rtol=1e-07, atol=0, err_msg="", verbose=True -------- np.assert_allclose """ - if type(actual) != type(desired): + if type(actual) is not type(desired): raise AssertionError("%s != %s" % (type(actual), type(desired))) return assert_allclose( actual, @@ -313,7 +313,7 @@ def check_arrays(x, y, err_msg="", verbose=True, check_dtypes=True): -------- np.assert_array_equal """ - assert type(x) == type(y), "{x} != {y}".format(x=type(x), y=type(y)) + assert type(x) is type(y), "{x} != {y}".format(x=type(x), y=type(y)) assert x.dtype == y.dtype, "{x.dtype} != {y.dtype}".format(x=x, y=y) if isinstance(x, LabelArray): diff --git a/src/zipline/testing/fixtures.py b/src/zipline/testing/fixtures.py index bdf56c200f..fa957eeac3 100644 --- a/src/zipline/testing/fixtures.py +++ b/src/zipline/testing/fixtures.py @@ -1017,7 +1017,6 @@ class level fixtures. BCOLZ_DAILY_BAR_PATH = "daily_equity_pricing.bcolz" BCOLZ_DAILY_BAR_READ_ALL_THRESHOLD = None - BCOLZ_DAILY_BAR_COUNTRY_CODE = None EQUITY_DAILY_BAR_SOURCE_FROM_MINUTE = False # allows WithBcolzEquityDailyBarReaderFromCSVs to call the # `write_csvs`method without needing to reimplement `init_class_fixtures` diff --git a/src/zipline/testing/predicates.py b/src/zipline/testing/predicates.py index 24b3e98225..0bdd616a84 100644 --- a/src/zipline/testing/predicates.py +++ b/src/zipline/testing/predicates.py @@ -544,7 +544,7 @@ def assert_timestamp_and_datetime_equal( Returns raises unless ``allow_datetime_coercions`` is passed as True. """ - assert allow_datetime_coercions or type(result) == type(expected), ( + assert allow_datetime_coercions or type(result) is type(expected), ( "%sdatetime types (%s, %s) don't match and " "allow_datetime_coercions was not set.\n%s" % ( diff --git a/src/zipline/utils/factory.py b/src/zipline/utils/factory.py index 296cd7388c..f3f8ad4922 100644 --- a/src/zipline/utils/factory.py +++ b/src/zipline/utils/factory.py @@ -42,7 +42,7 @@ def create_simulation_parameters( if start is None: start = pd.Timestamp(f"{year}-01-01", tz="UTC") - elif type(start) == datetime: + elif type(start) is datetime: start = pd.Timestamp(start) if end is None: @@ -51,7 +51,7 @@ def create_simulation_parameters( end = trading_calendar.sessions[start_index + num_days - 1] else: end = pd.Timestamp(f"{year}-12-31", tz="UTC") - elif type(end) == datetime: + elif type(end) is datetime: end = pd.Timestamp(end) sim_params = SimulationParameters(