From 77520e74f96e8f0a130d86941f6abe0ea3f2e525 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Tue, 22 Apr 2025 07:44:50 -0400 Subject: [PATCH 1/5] test: cleanup and lint for unused arguments in test functions --- ibis/backends/athena/tests/conftest.py | 2 +- ibis/backends/bigquery/tests/conftest.py | 2 +- .../bigquery/tests/system/test_connect.py | 2 +- .../tests/system/udf/test_udf_execute.py | 2 +- .../bigquery/tests/unit/udf/test_core.py | 8 ++-- .../bigquery/tests/unit/udf/test_usage.py | 2 +- ibis/backends/clickhouse/tests/conftest.py | 6 ++- .../clickhouse/tests/test_aggregations.py | 44 +++++++++---------- ibis/backends/clickhouse/tests/test_client.py | 4 +- .../clickhouse/tests/test_functions.py | 4 +- ibis/backends/databricks/tests/conftest.py | 2 +- ibis/backends/datafusion/tests/conftest.py | 2 +- ibis/backends/datafusion/tests/test_udf.py | 4 +- ibis/backends/druid/tests/conftest.py | 2 +- ibis/backends/duckdb/tests/conftest.py | 8 ++-- ibis/backends/duckdb/tests/test_datatypes.py | 4 +- .../duckdb/tests/test_decompile_tpch.py | 2 +- ibis/backends/duckdb/tests/test_geospatial.py | 2 +- ibis/backends/exasol/tests/conftest.py | 2 +- ibis/backends/flink/tests/conftest.py | 4 +- ibis/backends/impala/tests/conftest.py | 2 +- ibis/backends/mssql/tests/conftest.py | 2 +- ibis/backends/mssql/tests/test_client.py | 8 ++++ ibis/backends/mssql/tests/test_window.py | 11 ----- ibis/backends/mysql/tests/conftest.py | 2 +- ibis/backends/oracle/tests/conftest.py | 37 +++++----------- ibis/backends/oracle/tests/test_client.py | 2 +- ibis/backends/polars/tests/conftest.py | 2 +- ibis/backends/polars/tests/test_udf.py | 4 +- ibis/backends/postgres/tests/conftest.py | 2 +- .../postgres/tests/test_geospatial.py | 18 ++++---- ibis/backends/postgres/tests/test_udf.py | 2 +- ibis/backends/pyspark/tests/conftest.py | 10 ++--- ibis/backends/pyspark/tests/test_basic.py | 2 +- ibis/backends/risingwave/tests/conftest.py | 2 +- .../risingwave/tests/test_functions.py | 34 +++++++------- .../risingwave/tests/test_streaming.py | 2 +- ibis/backends/snowflake/tests/conftest.py | 2 +- ibis/backends/sqlite/tests/conftest.py | 4 +- ibis/backends/tests/base.py | 2 +- .../tests/signature/tests/test_compatible.py | 20 ++++----- ibis/backends/tests/sql/test_sql.py | 2 +- ibis/backends/tests/test_array.py | 5 ++- ibis/backends/tests/test_client.py | 7 ++- ibis/backends/tests/test_impure.py | 2 +- ibis/backends/tests/test_io.py | 2 +- ibis/backends/tests/test_markers.py | 24 +++++----- ibis/backends/tests/test_numeric.py | 38 +++++++--------- ibis/backends/tests/test_string.py | 4 +- ibis/backends/trino/tests/conftest.py | 2 +- ibis/common/tests/test_annotations.py | 18 ++++---- ibis/common/tests/test_bases.py | 2 +- ibis/common/tests/test_deferred.py | 2 +- ibis/common/tests/test_dispatch.py | 18 ++++---- ibis/common/tests/test_egraph.py | 4 +- ibis/common/tests/test_graph.py | 4 +- ibis/common/tests/test_patterns.py | 8 ++-- ibis/expr/tests/test_format.py | 2 +- ibis/expr/tests/test_reductions.py | 12 ++--- ibis/tests/expr/mocks.py | 4 +- ibis/tests/expr/test_case.py | 2 +- ibis/tests/expr/test_table.py | 18 ++++---- ibis/tests/expr/test_temporal.py | 8 ++-- ibis/tests/expr/test_timestamp.py | 4 +- ibis/tests/expr/test_udf.py | 8 ++-- ibis/tests/expr/test_window_frames.py | 2 +- pyproject.toml | 2 + 67 files changed, 232 insertions(+), 250 deletions(-) delete mode 100644 ibis/backends/mssql/tests/test_window.py diff --git a/ibis/backends/athena/tests/conftest.py b/ibis/backends/athena/tests/conftest.py index 7b31c0565e2d..3a51122076b9 100644 --- a/ibis/backends/athena/tests/conftest.py +++ b/ibis/backends/athena/tests/conftest.py @@ -101,7 +101,7 @@ def postload(self, **kw): self.connection = self.connect(schema_name=IBIS_ATHENA_TEST_DATABASE, **kw) @staticmethod - def connect(*, tmpdir, worker_id, **kw) -> BaseBackend: + def connect(*, tmpdir, worker_id, **kw) -> BaseBackend: # noqa: ARG004 return ibis.athena.connect(**CONNECT_ARGS, **kw) def _remap_column_names(self, table_name: str) -> dict[str, str]: diff --git a/ibis/backends/bigquery/tests/conftest.py b/ibis/backends/bigquery/tests/conftest.py index 6ec942e92a5a..094a61bf2fc0 100644 --- a/ibis/backends/bigquery/tests/conftest.py +++ b/ibis/backends/bigquery/tests/conftest.py @@ -64,7 +64,7 @@ def _load_data(self, **_: Any) -> None: query.result() @staticmethod - def connect(*, tmpdir, worker_id, **kw) -> Backend: + def connect(*, tmpdir, worker_id, **kw) -> Backend: # noqa: ARG004 """Connect to the test project and dataset.""" credentials, default_project_id = google.auth.default( scopes=EXTERNAL_DATA_SCOPES diff --git a/ibis/backends/bigquery/tests/system/test_connect.py b/ibis/backends/bigquery/tests/system/test_connect.py index 151bbb55f8aa..14e85fe709c6 100644 --- a/ibis/backends/bigquery/tests/system/test_connect.py +++ b/ibis/backends/bigquery/tests/system/test_connect.py @@ -30,7 +30,7 @@ def test_repeated_project_name(project_id, credentials): def test_project_id_different_from_default_credentials(monkeypatch): creds = mock.create_autospec(auth.Credentials) - def mock_credentials(*args, **kwargs): + def mock_credentials(*_, **__): return creds, "default-project-id" monkeypatch.setattr(pydata_google_auth, "default", mock_credentials) diff --git a/ibis/backends/bigquery/tests/system/udf/test_udf_execute.py b/ibis/backends/bigquery/tests/system/udf/test_udf_execute.py index 3ed42d9b32cc..7d8fb4291da0 100644 --- a/ibis/backends/bigquery/tests/system/udf/test_udf_execute.py +++ b/ibis/backends/bigquery/tests/system/udf/test_udf_execute.py @@ -45,7 +45,7 @@ def my_add(a: float, b: float) -> float: ) -def test_udf_with_struct(alltypes, df, snapshot): +def test_udf_with_struct(alltypes, df): @udf.scalar.python def my_struct_thing(a: float, b: float) -> dt.Struct( {"width": float, "height": float} diff --git a/ibis/backends/bigquery/tests/unit/udf/test_core.py b/ibis/backends/bigquery/tests/unit/udf/test_core.py index 1209ec4fd22b..022a15144a0f 100644 --- a/ibis/backends/bigquery/tests/unit/udf/test_core.py +++ b/ibis/backends/bigquery/tests/unit/udf/test_core.py @@ -40,7 +40,7 @@ def f(): def test_yield(snapshot): - def f(a): + def f(_): yield from [1, 2, 3] js = compile(f) @@ -235,7 +235,7 @@ def test_class_with_properties(snapshot): def test_set_to_object(snapshot): - def f(a): + def f(_): x = set() y = 1 x.add(y) @@ -246,7 +246,7 @@ def f(a): def test_setitem(snapshot): - def f(a): + def f(_): x = {} y = "2" x[y] = y @@ -271,7 +271,7 @@ def f(a): def test_scope_with_while(snapshot): def f(): - class Foo: + class _: def do_stuff(self): while True: i = 1 diff --git a/ibis/backends/bigquery/tests/unit/udf/test_usage.py b/ibis/backends/bigquery/tests/unit/udf/test_usage.py index 4f8dd4218d36..ad92703393f6 100644 --- a/ibis/backends/bigquery/tests/unit/udf/test_usage.py +++ b/ibis/backends/bigquery/tests/unit/udf/test_usage.py @@ -66,7 +66,7 @@ def my_len(s: str) -> float: def test_udf_int64(argument_type, return_type): # invalid argument type, valid return type @udf.scalar.python(signature=((argument_type,), return_type)) - def my_func(x): + def my_func(_): return 1 expr = my_func(None) diff --git a/ibis/backends/clickhouse/tests/conftest.py b/ibis/backends/clickhouse/tests/conftest.py index 4e70a3d4cf73..ac0b53b9e1fb 100644 --- a/ibis/backends/clickhouse/tests/conftest.py +++ b/ibis/backends/clickhouse/tests/conftest.py @@ -79,7 +79,11 @@ def postload(self, **kw: Any): @staticmethod def connect( - *, tmpdir, worker_id, settings: Mapping[str, Any] | None = None, **kw: Any + *, + tmpdir, # noqa: ARG004 + worker_id, # noqa: ARG004 + settings: Mapping[str, Any] | None = None, + **kw: Any, ): if settings is None: settings = {} diff --git a/ibis/backends/clickhouse/tests/test_aggregations.py b/ibis/backends/clickhouse/tests/test_aggregations.py index c9e5bb38c9ad..d25541b5d542 100644 --- a/ibis/backends/clickhouse/tests/test_aggregations.py +++ b/ibis/backends/clickhouse/tests/test_aggregations.py @@ -45,48 +45,48 @@ def test_reduction_invalid_where(alltypes, reduction): ("func", "pandas_func"), [ ( - lambda t, cond: t.bool_col.count(), - lambda df, cond: df.bool_col.count(), + lambda t, _: t.bool_col.count(), + lambda df, _: df.bool_col.count(), ), ( - lambda t, cond: t.bool_col.approx_nunique(), - lambda df, cond: df.bool_col.nunique(), + lambda t, _: t.bool_col.approx_nunique(), + lambda df, _: df.bool_col.nunique(), ), ( - lambda t, cond: t.double_col.sum(), - lambda df, cond: df.double_col.sum(), + lambda t, _: t.double_col.sum(), + lambda df, _: df.double_col.sum(), ), ( - lambda t, cond: t.double_col.mean(), - lambda df, cond: df.double_col.mean(), + lambda t, _: t.double_col.mean(), + lambda df, _: df.double_col.mean(), ), ( - lambda t, cond: t.int_col.approx_median(), - lambda df, cond: df.int_col.median(), + lambda t, _: t.int_col.approx_median(), + lambda df, _: df.int_col.median(), ), ( - lambda t, cond: t.double_col.min(), - lambda df, cond: df.double_col.min(), + lambda t, _: t.double_col.min(), + lambda df, _: df.double_col.min(), ), ( - lambda t, cond: t.double_col.max(), - lambda df, cond: df.double_col.max(), + lambda t, _: t.double_col.max(), + lambda df, _: df.double_col.max(), ), ( - lambda t, cond: t.double_col.var(), - lambda df, cond: df.double_col.var(), + lambda t, _: t.double_col.var(), + lambda df, _: df.double_col.var(), ), ( - lambda t, cond: t.double_col.std(), - lambda df, cond: df.double_col.std(), + lambda t, _: t.double_col.std(), + lambda df, _: df.double_col.std(), ), ( - lambda t, cond: t.double_col.var(how="sample"), - lambda df, cond: df.double_col.var(ddof=1), + lambda t, _: t.double_col.var(how="sample"), + lambda df, _: df.double_col.var(ddof=1), ), ( - lambda t, cond: t.double_col.std(how="pop"), - lambda df, cond: df.double_col.std(ddof=0), + lambda t, _: t.double_col.std(how="pop"), + lambda df, _: df.double_col.std(ddof=0), ), ( lambda t, cond: t.bool_col.count(where=cond), diff --git a/ibis/backends/clickhouse/tests/test_client.py b/ibis/backends/clickhouse/tests/test_client.py index 87040c6848a9..b43fb8f64a47 100644 --- a/ibis/backends/clickhouse/tests/test_client.py +++ b/ibis/backends/clickhouse/tests/test_client.py @@ -380,13 +380,13 @@ def test_password_with_bracket(): ibis.clickhouse.connect(host=host, user=user, port=port, password=quoted_pass) -def test_from_url(con): +def test_from_url(): assert ibis.connect( f"clickhouse://{CLICKHOUSE_USER}:{CLICKHOUSE_PASS}@{CLICKHOUSE_HOST}:{CLICKHOUSE_PORT}/{IBIS_TEST_CLICKHOUSE_DB}" ) -def test_from_url_with_kwargs(con): +def test_from_url_with_kwargs(): # since explicit kwargs take precedence, this passes, because we're passing # `database` explicitly, even though our connection string says to use a # random database diff --git a/ibis/backends/clickhouse/tests/test_functions.py b/ibis/backends/clickhouse/tests/test_functions.py index 2637860c4a74..687a60dc4d1e 100644 --- a/ibis/backends/clickhouse/tests/test_functions.py +++ b/ibis/backends/clickhouse/tests/test_functions.py @@ -78,13 +78,13 @@ def test_timestamp_cast(alltypes, assert_sql): assert_sql(result2, "out2.sql") -def test_timestamp_now(con, assert_sql): +def test_timestamp_now(assert_sql): expr = ibis.now() assert_sql(expr) @pytest.mark.parametrize("unit", ["y", "m", "d", "w", "h", "minute"]) -def test_timestamp_truncate(con, unit, assert_sql): +def test_timestamp_truncate(unit, assert_sql): stamp = ibis.timestamp("2009-05-17 12:34:56") expr = stamp.truncate(unit) assert_sql(expr) diff --git a/ibis/backends/databricks/tests/conftest.py b/ibis/backends/databricks/tests/conftest.py index e1fe05cf0681..f0bdb21aa86b 100644 --- a/ibis/backends/databricks/tests/conftest.py +++ b/ibis/backends/databricks/tests/conftest.py @@ -66,7 +66,7 @@ def _load_data(self, **_: Any) -> None: cur.execute(stmt) @staticmethod - def connect(*, tmpdir, worker_id, **kw) -> BaseBackend: + def connect(*, tmpdir, worker_id, **kw) -> BaseBackend: # noqa: ARG004 return ibis.databricks.connect( server_hostname=env["DATABRICKS_SERVER_HOSTNAME"], http_path=env["DATABRICKS_HTTP_PATH"], diff --git a/ibis/backends/datafusion/tests/conftest.py b/ibis/backends/datafusion/tests/conftest.py index ee7f269a7efe..ba3fa8c03079 100644 --- a/ibis/backends/datafusion/tests/conftest.py +++ b/ibis/backends/datafusion/tests/conftest.py @@ -34,7 +34,7 @@ def _load_data(self, **_: Any) -> None: con.create_table("topk", topk) @staticmethod - def connect(*, tmpdir, worker_id, **kw): + def connect(*, tmpdir, worker_id, **kw): # noqa: ARG004 return ibis.datafusion.connect(**kw) def _load_tpc(self, *, suite, scale_factor): diff --git a/ibis/backends/datafusion/tests/test_udf.py b/ibis/backends/datafusion/tests/test_udf.py index a05f5d33a4cb..46ab79db21b5 100644 --- a/ibis/backends/datafusion/tests/test_udf.py +++ b/ibis/backends/datafusion/tests/test_udf.py @@ -14,12 +14,12 @@ with pytest.warns(FutureWarning, match="v9.0"): @elementwise(input_type=["string"], output_type="int64") - def my_string_length(arr, **kwargs): + def my_string_length(arr, **_): # arr is a pyarrow.StringArray return pc.cast(pc.multiply(pc.utf8_length(arr), 2), target_type="int64") @elementwise(input_type=[dt.int64, dt.int64], output_type=dt.int64) - def my_add(arr1, arr2, **kwargs): + def my_add(arr1, arr2, **_): return pc.add(arr1, arr2) @reduction(input_type=[dt.float64], output_type=dt.float64) diff --git a/ibis/backends/druid/tests/conftest.py b/ibis/backends/druid/tests/conftest.py index 9e8b725d207e..d04e449853e7 100644 --- a/ibis/backends/druid/tests/conftest.py +++ b/ibis/backends/druid/tests/conftest.py @@ -145,5 +145,5 @@ def _load_data(self, **_: Any) -> None: fut.result() @staticmethod - def connect(*, tmpdir, worker_id, **kw): + def connect(*, tmpdir, worker_id, **kw): # noqa: ARG004 return ibis.connect(DRUID_URL, **kw) diff --git a/ibis/backends/duckdb/tests/conftest.py b/ibis/backends/duckdb/tests/conftest.py index 1f517412595c..555d744c130c 100644 --- a/ibis/backends/duckdb/tests/conftest.py +++ b/ibis/backends/duckdb/tests/conftest.py @@ -97,7 +97,7 @@ def ddl_script(self) -> Iterator[str]: yield from super().ddl_script @staticmethod - def connect(*, tmpdir, worker_id, **kw) -> BaseBackend: + def connect(*, tmpdir, worker_id, **kw) -> BaseBackend: # noqa: ARG004 # use an extension directory per test worker to prevent simultaneous # downloads on windows # @@ -150,12 +150,12 @@ def gpd(): @pytest.fixture(scope="session") -def zones(con, data_dir, gpd): +def zones(con, data_dir): return con.read_geo(data_dir / "geojson" / "zones.geojson") @pytest.fixture(scope="session") -def lines(con, data_dir, gpd): +def lines(con, data_dir): return con.read_geo(data_dir / "geojson" / "lines.geojson") @@ -170,7 +170,7 @@ def lines_gdf(data_dir, gpd): @pytest.fixture(scope="session") -def geotable(con, gpd): +def geotable(con): return con.table("geo") diff --git a/ibis/backends/duckdb/tests/test_datatypes.py b/ibis/backends/duckdb/tests/test_datatypes.py index f5cb74bd2273..27104d59f8e1 100644 --- a/ibis/backends/duckdb/tests/test_datatypes.py +++ b/ibis/backends/duckdb/tests/test_datatypes.py @@ -122,7 +122,7 @@ def test_cast_to_floating_point_type(con, snapshot, typ): snapshot.assert_match(sql, "out.sql") -def null_literal(array_min_size: int = 0, array_max_size: int | None = None): +def null_literal(): true = st.just(True) field_names = st.text(alphabet=string.ascii_lowercase + string.digits, min_size=1) @@ -162,7 +162,7 @@ def null_literal(array_min_size: int = 0, array_max_size: int | None = None): ) -@h.given(lit=null_literal(array_min_size=1, array_max_size=8192)) +@h.given(lit=null_literal()) @h.settings(suppress_health_check=[h.HealthCheck.function_scoped_fixture]) def test_null_scalar(con, lit, monkeypatch): monkeypatch.setattr(ibis.options, "default_backend", con) diff --git a/ibis/backends/duckdb/tests/test_decompile_tpch.py b/ibis/backends/duckdb/tests/test_decompile_tpch.py index 2ab3d67d82d4..e269a372c00c 100644 --- a/ibis/backends/duckdb/tests/test_decompile_tpch.py +++ b/ibis/backends/duckdb/tests/test_decompile_tpch.py @@ -73,7 +73,7 @@ def set_database(con, db): param(3, id="tpch03"), ], ) -def test_parse_sql_tpch(tpch_query, snapshot, con, data_dir): +def test_parse_sql_tpch(tpch_query, snapshot, con): tpch_query_file = SQL_QUERY_PATH / f"{tpch_query:02d}.sql" with open(tpch_query_file) as f: sql = f.read() diff --git a/ibis/backends/duckdb/tests/test_geospatial.py b/ibis/backends/duckdb/tests/test_geospatial.py index 86368f1045ed..9d664d42af67 100644 --- a/ibis/backends/duckdb/tests/test_geospatial.py +++ b/ibis/backends/duckdb/tests/test_geospatial.py @@ -262,7 +262,7 @@ def test_create_table_geospatial_types(geotable, con): @pytest.mark.parametrize("expr", [point, point_geom]) -def test_literal_geospatial_explicit(con, expr, assert_sql): +def test_literal_geospatial_explicit(expr, assert_sql): assert_sql(expr) diff --git a/ibis/backends/exasol/tests/conftest.py b/ibis/backends/exasol/tests/conftest.py index ae9b07f8135a..6b6fba0e150c 100644 --- a/ibis/backends/exasol/tests/conftest.py +++ b/ibis/backends/exasol/tests/conftest.py @@ -39,7 +39,7 @@ class TestConf(ServiceBackendTest): deps = ("pyexasol",) @staticmethod - def connect(*, tmpdir, worker_id, **kw: Any): + def connect(*, tmpdir, worker_id, **kw: Any): # noqa: ARG004 return ibis.exasol.connect( user=EXASOL_USER, password=EXASOL_PASS, diff --git a/ibis/backends/flink/tests/conftest.py b/ibis/backends/flink/tests/conftest.py index 5fae4ed11e0a..6333725e9ab0 100644 --- a/ibis/backends/flink/tests/conftest.py +++ b/ibis/backends/flink/tests/conftest.py @@ -89,7 +89,7 @@ class TestConf(BackendTest): deps = "pandas", "pyflink" @staticmethod - def connect(*, tmpdir, worker_id, **kw: Any): + def connect(*, tmpdir, worker_id, **kw: Any): # noqa: ARG004 """Flink backend is created in batch mode by default. This is to comply with the assumption that the tests under ibis/ibis/backends/tests/ are for batch (storage or processing) backends. @@ -125,7 +125,7 @@ def _load_data(self, **_: Any) -> None: class TestConfForStreaming(TestConf): @staticmethod - def connect(*, tmpdir, worker_id, **kw: Any): + def connect(*, tmpdir, worker_id, **kw: Any): # noqa: ARG004 """Flink backend is created in streaming mode here. To be used in the tests under ibis/ibis/backends/flink/tests/. We only use mini cluster here for simplicity. diff --git a/ibis/backends/impala/tests/conftest.py b/ibis/backends/impala/tests/conftest.py index 922e7063898f..f17eee39315a 100644 --- a/ibis/backends/impala/tests/conftest.py +++ b/ibis/backends/impala/tests/conftest.py @@ -124,7 +124,7 @@ def postload(self, **kw): self.connection = self.connect(database=env.test_data_db, **kw) @staticmethod - def connect(*, tmpdir, worker_id, **kw): + def connect(*, tmpdir, worker_id, **kw): # noqa: ARG004 env = IbisTestEnv() return ibis.impala.connect(host=env.impala_host, port=env.impala_port, **kw) diff --git a/ibis/backends/mssql/tests/conftest.py b/ibis/backends/mssql/tests/conftest.py index 407692bf4451..6f1b7495e2bf 100644 --- a/ibis/backends/mssql/tests/conftest.py +++ b/ibis/backends/mssql/tests/conftest.py @@ -47,7 +47,7 @@ def _load_data(self, *, database: str = IBIS_TEST_MSSQL_DB, **_): super()._load_data(database=database, **_) @staticmethod - def connect(*, tmpdir, worker_id, **kw): + def connect(*, tmpdir, worker_id, **kw): # noqa: ARG004 return ibis.mssql.connect( host=MSSQL_HOST, user=MSSQL_USER, diff --git a/ibis/backends/mssql/tests/test_client.py b/ibis/backends/mssql/tests/test_client.py index 323a1ad60f1b..573095aab279 100644 --- a/ibis/backends/mssql/tests/test_client.py +++ b/ibis/backends/mssql/tests/test_client.py @@ -347,3 +347,11 @@ def test_mssql_without_password_is_valid(): ) def test_list_tables_with_dash(con, database): assert con.list_tables(database=database) + + +def test_rank_no_window_frame(snapshot): + t = ibis.table(schema=dict(color=str, price=int), name="diamonds_sample") + expr = t.mutate(ibis.rank().over(group_by="color", order_by="price")) + sql = ibis.to_sql(expr, dialect="mssql") + + snapshot.assert_match(sql, "out.sql") diff --git a/ibis/backends/mssql/tests/test_window.py b/ibis/backends/mssql/tests/test_window.py deleted file mode 100644 index 6b8aca351153..000000000000 --- a/ibis/backends/mssql/tests/test_window.py +++ /dev/null @@ -1,11 +0,0 @@ -from __future__ import annotations - -import ibis - - -def test_rank_no_window_frame(con, snapshot): - t = ibis.table(schema=dict(color=str, price=int), name="diamonds_sample") - expr = t.mutate(ibis.rank().over(group_by="color", order_by="price")) - sql = ibis.to_sql(expr, dialect="mssql") - - snapshot.assert_match(sql, "out.sql") diff --git a/ibis/backends/mysql/tests/conftest.py b/ibis/backends/mysql/tests/conftest.py index 4ec476062951..02c6b552549b 100644 --- a/ibis/backends/mysql/tests/conftest.py +++ b/ibis/backends/mysql/tests/conftest.py @@ -61,7 +61,7 @@ def _load_data(self, **kwargs: Any) -> None: cur.execute("\n".join(lines)) @staticmethod - def connect(*, tmpdir, worker_id, **kw): + def connect(*, tmpdir, worker_id, **kw): # noqa: ARG004 return ibis.mysql.connect( host=MYSQL_HOST, user=MYSQL_USER, diff --git a/ibis/backends/oracle/tests/conftest.py b/ibis/backends/oracle/tests/conftest.py index b0cf5d2fb385..1c60b3fde1cf 100644 --- a/ibis/backends/oracle/tests/conftest.py +++ b/ibis/backends/oracle/tests/conftest.py @@ -92,7 +92,6 @@ def _load_data( dsn=oracledb.makedsn(host, port, service_name=database), user=user, password=password, - database=database, schema=self.ddl_script, ) @@ -117,7 +116,7 @@ def _load_data( fut.result() @staticmethod - def connect(*, tmpdir, worker_id, **kw): + def connect(*, tmpdir, worker_id, **kw): # noqa: ARG004 return ibis.oracle.connect( host=ORACLE_HOST, user=ORACLE_USER, @@ -139,29 +138,13 @@ def con(tmp_path_factory, data_dir, worker_id): def init_oracle_database( - user: str, - password: str, - dsn: str, - database: str, - schema: str | None = None, - **kwargs: Any, + user: str, password: str, dsn: str, schema: str | None = None ) -> None: - """Initialise `database` at `url` with `schema`. - - Parameters - ---------- - database : str - Name of the database to be dropped - schema : TextIO - File object containing schema to use - """ - - con = oracledb.connect(dsn, user=user, password=password, stmtcachesize=0) - - if schema: - with con.cursor() as cursor: - for stmt in schema: - # XXX: maybe should just remove the comments in the sql file - # so we don't end up writing an entire parser here. - if not stmt.startswith("--"): - cursor.execute(stmt) + with oracledb.connect( + dsn, user=user, password=password, stmtcachesize=0 + ).cursor() as cursor: + for stmt in schema: + # XXX: maybe should just remove the comments in the sql file + # so we don't end up writing an entire parser here. + if not stmt.startswith("--"): + cursor.execute(stmt) diff --git a/ibis/backends/oracle/tests/test_client.py b/ibis/backends/oracle/tests/test_client.py index 21c5b7881804..e855fd67a539 100644 --- a/ibis/backends/oracle/tests/test_client.py +++ b/ibis/backends/oracle/tests/test_client.py @@ -79,7 +79,7 @@ def test_from_url(): assert result.a.iat[0] == 1 -def test_invalid_port(con): +def test_invalid_port(): port = 9999 url = f"oracle://{ORACLE_USER}:{ORACLE_PASS}@{ORACLE_HOST}:{port}/IBIS_TESTING" with pytest.raises( diff --git a/ibis/backends/polars/tests/conftest.py b/ibis/backends/polars/tests/conftest.py index 5033fc25d813..c7705348da69 100644 --- a/ibis/backends/polars/tests/conftest.py +++ b/ibis/backends/polars/tests/conftest.py @@ -29,7 +29,7 @@ def _load_data(self, **_: Any) -> None: con.create_table("topk", topk) @staticmethod - def connect(*, tmpdir, worker_id, **kw): + def connect(*, tmpdir, worker_id, **kw): # noqa: ARG004 return ibis.polars.connect(**kw) @classmethod diff --git a/ibis/backends/polars/tests/test_udf.py b/ibis/backends/polars/tests/test_udf.py index f79295fd82c0..949467cabf02 100644 --- a/ibis/backends/polars/tests/test_udf.py +++ b/ibis/backends/polars/tests/test_udf.py @@ -15,13 +15,13 @@ with pytest.warns(FutureWarning, match="v9.0"): @elementwise(input_type=["string"], output_type="int64") - def my_string_length(arr, **kwargs): + def my_string_length(arr, **_): return pl.from_arrow( pc.cast(pc.multiply(pc.utf8_length(arr.to_arrow()), 2), target_type="int64") ) @elementwise(input_type=[dt.int64, dt.int64], output_type=dt.int64) - def my_add(arr1, arr2, **kwargs): + def my_add(arr1, arr2, **_): return pl.from_arrow(pc.add(arr1.to_arrow(), arr2.to_arrow())) @reduction(input_type=[dt.float64], output_type=dt.float64) diff --git a/ibis/backends/postgres/tests/conftest.py b/ibis/backends/postgres/tests/conftest.py index d985c7eb43a9..6ed9d34a1c7c 100644 --- a/ibis/backends/postgres/tests/conftest.py +++ b/ibis/backends/postgres/tests/conftest.py @@ -64,7 +64,7 @@ def test_files(self) -> Iterable[Path]: return self.data_dir.joinpath("csv").glob("*.csv") @staticmethod - def connect(*, tmpdir, worker_id, **kw): + def connect(*, tmpdir, worker_id, **kw): # noqa: ARG004 return ibis.postgres.connect( host=PG_HOST, port=PG_PORT, diff --git a/ibis/backends/postgres/tests/test_geospatial.py b/ibis/backends/postgres/tests/test_geospatial.py index 48b30fe130ec..871400b8b3f8 100644 --- a/ibis/backends/postgres/tests/test_geospatial.py +++ b/ibis/backends/postgres/tests/test_geospatial.py @@ -292,8 +292,8 @@ def test_set_srid(geotable, condition, expected): @pytest.mark.parametrize( ("condition", "expected"), [ - (lambda t: point_geom_0.transform(900913).srid(), 900913), - (lambda t: point_geom_2.transform(900913).srid(), 900913), + (lambda _: point_geom_0.transform(900913).srid(), 900913), + (lambda _: point_geom_2.transform(900913).srid(), 900913), ( lambda t: t.geo_point.set_srid(4326).transform(900913).srid(), 900913, @@ -323,12 +323,12 @@ def test_transform(geotable, condition, expected): "expr_fn", [ param(lambda t: t.geo_point.set_srid(4326), id="geom_geo_point"), - param(lambda t: point_geom_0, id="point_geom_0"), - param(lambda t: point_geom_1, id="point_geom_1"), - param(lambda t: point_geom_2, id="point_geom_2"), - param(lambda t: point_geog_0, id="point_geog_0"), - param(lambda t: point_geog_1, id="point_geog_1"), - param(lambda t: point_geog_2, id="point_geog_2"), + param(lambda _: point_geom_0, id="point_geom_0"), + param(lambda _: point_geom_1, id="point_geom_1"), + param(lambda _: point_geom_2, id="point_geom_2"), + param(lambda _: point_geog_0, id="point_geog_0"), + param(lambda _: point_geog_1, id="point_geog_1"), + param(lambda _: point_geog_2, id="point_geog_2"), ], ) def test_cast_geography(geotable, expr_fn): @@ -425,7 +425,7 @@ def test_geo_dataframe(geotable): ), ], ) -def test_geo_literals_smoke(con, shape, value, modifier, assert_sql): +def test_geo_literals_smoke(shape, value, modifier, assert_sql): """Smoke tests for geo spatial literals.""" expr = ibis.literal(value, type=getattr(dt, shape).copy(**modifier)) assert_sql(expr) diff --git a/ibis/backends/postgres/tests/test_udf.py b/ibis/backends/postgres/tests/test_udf.py index af4846314c21..bf4ceae24420 100644 --- a/ibis/backends/postgres/tests/test_udf.py +++ b/ibis/backends/postgres/tests/test_udf.py @@ -69,7 +69,7 @@ def sql_define_udf(test_database): @pytest.fixture(scope="session") -def con_for_udf(con, sql_table_setup, sql_define_udf, sql_define_py_udf, test_database): +def con_for_udf(con, sql_table_setup, sql_define_udf, sql_define_py_udf, test_database): # noqa: ARG001 with con.begin() as c: c.execute(sql_table_setup) c.execute(sql_define_udf) diff --git a/ibis/backends/pyspark/tests/conftest.py b/ibis/backends/pyspark/tests/conftest.py index 15c29dc5d1bb..cadddabb9af6 100644 --- a/ibis/backends/pyspark/tests/conftest.py +++ b/ibis/backends/pyspark/tests/conftest.py @@ -246,7 +246,7 @@ def test_files(self) -> Iterable[Path]: return self.data_dir.joinpath("parquet").glob("*.parquet") @staticmethod - def connect(*, tmpdir, worker_id, **kw): + def connect(*, tmpdir, worker_id, **kw): # noqa: ARG004 from pyspark.sql import SparkSession spark = ( @@ -257,10 +257,10 @@ def connect(*, tmpdir, worker_id, **kw): return ibis.pyspark.connect(spark, **kw) @pytest.fixture(scope="session") - def con_streaming(data_dir, tmp_path_factory, worker_id): + def con_streaming(data_dir, tmp_path_factory, worker_id): # noqa: ARG001 pytest.skip("Streaming tests are not supported in remote mode") - def write_to_memory(self, expr, table_name): + def write_to_memory(self, *_): assert self.mode == "batch" raise NotImplementedError else: @@ -273,7 +273,7 @@ def parquet_dir(self) -> str: return str(self.data_dir / "parquet") @staticmethod - def connect(*, tmpdir, worker_id, **kw): + def connect(*, tmpdir, worker_id, **kw): # noqa: ARG004 from pyspark.sql import SparkSession config = SparkSession.builder.appName("ibis_testing") @@ -372,7 +372,7 @@ def load_data( return inst @staticmethod - def connect(*, tmpdir, worker_id, **kw): + def connect(*, tmpdir, worker_id, **kw): # noqa: ARG004 from pyspark.sql import SparkSession # SparkContext is shared globally; only one SparkContext should be active diff --git a/ibis/backends/pyspark/tests/test_basic.py b/ibis/backends/pyspark/tests/test_basic.py index 95bafb4690dd..8d13970862fd 100644 --- a/ibis/backends/pyspark/tests/test_basic.py +++ b/ibis/backends/pyspark/tests/test_basic.py @@ -110,7 +110,7 @@ def test_cast(t, df): tm.assert_frame_equal(result, df) -def test_alias_after_select(t, df): +def test_alias_after_select(t): # Regression test for issue 2136 table = t[["id"]] table = table.mutate(id2=table["id"]) diff --git a/ibis/backends/risingwave/tests/conftest.py b/ibis/backends/risingwave/tests/conftest.py index 55b6f5ea4521..f55dc504591a 100644 --- a/ibis/backends/risingwave/tests/conftest.py +++ b/ibis/backends/risingwave/tests/conftest.py @@ -53,7 +53,7 @@ def _load_data(self, **_: Any) -> None: pass @staticmethod - def connect(*, tmpdir, worker_id, port: int | None = None, **kw): + def connect(*, tmpdir, worker_id, port: int | None = None, **kw): # noqa: ARG004 con = ibis.risingwave.connect( host=PG_HOST, port=port or PG_PORT, diff --git a/ibis/backends/risingwave/tests/test_functions.py b/ibis/backends/risingwave/tests/test_functions.py index 38be06b1281d..d5126b28b3b2 100644 --- a/ibis/backends/risingwave/tests/test_functions.py +++ b/ibis/backends/risingwave/tests/test_functions.py @@ -203,7 +203,7 @@ def test_coalesce(con, expr, expected): ), ], ) -def test_coalesce_all_na(con, expr, expected): +def test_coalesce_all_na(con, expr): assert con.execute(expr) is None @@ -329,43 +329,43 @@ def test_union_cte(alltypes, distinct, assert_sql): ("func", "pandas_func"), [ param( - lambda t, cond: t.bool_col.count(), - lambda df, cond: df.bool_col.count(), + lambda t, _: t.bool_col.count(), + lambda df, _: df.bool_col.count(), id="count", ), param( - lambda t, cond: t.double_col.mean(), - lambda df, cond: df.double_col.mean(), + lambda t, _: t.double_col.mean(), + lambda df, _: df.double_col.mean(), id="mean", ), param( - lambda t, cond: t.double_col.min(), - lambda df, cond: df.double_col.min(), + lambda t, _: t.double_col.min(), + lambda df, _: df.double_col.min(), id="min", ), param( - lambda t, cond: t.double_col.max(), - lambda df, cond: df.double_col.max(), + lambda t, _: t.double_col.max(), + lambda df, _: df.double_col.max(), id="max", ), param( - lambda t, cond: t.double_col.var(), - lambda df, cond: df.double_col.var(), + lambda t, _: t.double_col.var(), + lambda df, _: df.double_col.var(), id="var", ), param( - lambda t, cond: t.double_col.std(), - lambda df, cond: df.double_col.std(), + lambda t, _: t.double_col.std(), + lambda df, _: df.double_col.std(), id="std", ), param( - lambda t, cond: t.double_col.var(how="sample"), - lambda df, cond: df.double_col.var(ddof=1), + lambda t, _: t.double_col.var(how="sample"), + lambda df, _: df.double_col.var(ddof=1), id="samp_var", ), param( - lambda t, cond: t.double_col.std(how="pop"), - lambda df, cond: df.double_col.std(ddof=0), + lambda t, _: t.double_col.std(how="pop"), + lambda df, _: df.double_col.std(ddof=0), id="pop_std", ), param( diff --git a/ibis/backends/risingwave/tests/test_streaming.py b/ibis/backends/risingwave/tests/test_streaming.py index df2e7edcb91a..7bba83edc7c7 100644 --- a/ibis/backends/risingwave/tests/test_streaming.py +++ b/ibis/backends/risingwave/tests/test_streaming.py @@ -90,7 +90,7 @@ def test_mv_on_table_with_connector(con): con.drop_table(tblc_name) -def test_sink_from(con, alltypes): +def test_sink_from(con): sk_name = util.gen_name("sk_from") con.create_sink( sk_name, diff --git a/ibis/backends/snowflake/tests/conftest.py b/ibis/backends/snowflake/tests/conftest.py index c6d18f13a54e..c7edc854615d 100644 --- a/ibis/backends/snowflake/tests/conftest.py +++ b/ibis/backends/snowflake/tests/conftest.py @@ -192,7 +192,7 @@ def _load_data(self, **_: Any) -> None: future.result() @staticmethod - def connect(*, tmpdir, worker_id, **kw) -> BaseBackend: + def connect(*, tmpdir, worker_id, **kw) -> BaseBackend: # noqa: ARG004 if os.environ.get("SNOWFLAKE_SNOWPARK"): import snowflake.snowpark as sp diff --git a/ibis/backends/sqlite/tests/conftest.py b/ibis/backends/sqlite/tests/conftest.py index 32e1633d006b..07785d4058e9 100644 --- a/ibis/backends/sqlite/tests/conftest.py +++ b/ibis/backends/sqlite/tests/conftest.py @@ -22,10 +22,10 @@ class TestConf(BackendTest): deps = ("regex",) @staticmethod - def connect(*, tmpdir, worker_id, **kw): + def connect(*, tmpdir, worker_id, **kw): # noqa: ARG004 return ibis.sqlite.connect(**kw) - def _load_data(self, **kw: Any) -> None: + def _load_data(self, **_: Any) -> None: """Load test data into a SQLite backend instance.""" with self.connection.begin() as con: for stmt in self.ddl_script: diff --git a/ibis/backends/tests/base.py b/ibis/backends/tests/base.py index a254b4c0d21f..f304847b9d5a 100644 --- a/ibis/backends/tests/base.py +++ b/ibis/backends/tests/base.py @@ -120,7 +120,7 @@ def name(cls) -> str: def connect(*, tmpdir, worker_id, **kw: Any): """Return a connection with data loaded from `data_dir`.""" - def _transform_tpc_sql(self, parsed, *, suite, leaves): + def _transform_tpc_sql(self, parsed, *, suite, leaves): # noqa: ARG002 return parsed def _load_data(self, **_: Any) -> None: diff --git a/ibis/backends/tests/signature/tests/test_compatible.py b/ibis/backends/tests/signature/tests/test_compatible.py index b96607228cbc..6c2a1e3139c8 100644 --- a/ibis/backends/tests/signature/tests/test_compatible.py +++ b/ibis/backends/tests/signature/tests/test_compatible.py @@ -35,20 +35,20 @@ def b5(posarg2: str, /): ... "a, b, check_annotations", [ param( - lambda posarg, *, kwarg1=None, kwarg2=None: ..., - lambda posarg, *, kwarg2=None, kwarg1=None: ..., + lambda posarg, *, kwarg1=None, kwarg2=None: ..., # noqa: ARG005 + lambda posarg, *, kwarg2=None, kwarg1=None: ..., # noqa: ARG005 True, id="swapped kwarg order", ), param( - lambda posarg, *, kwarg1=None, kwarg2=None, kwarg3=None: ..., - lambda posarg, *, kwarg2=None, kwarg1=None: ..., + lambda posarg, *, kwarg1=None, kwarg2=None, kwarg3=None: ..., # noqa: ARG005 + lambda posarg, *, kwarg2=None, kwarg1=None: ..., # noqa: ARG005 True, id="swapped kwarg order w/extra kwarg first", ), param( - lambda posarg, *, kwarg2=None, kwarg1=None: ..., - lambda posarg, *, kwarg1=None, kwarg2=None, kwarg3=None: ..., + lambda posarg, *, kwarg2=None, kwarg1=None: ..., # noqa: ARG005 + lambda posarg, *, kwarg1=None, kwarg2=None, kwarg3=None: ..., # noqa: ARG005 True, id="swapped kwarg order w/extra kwarg second", ), @@ -93,14 +93,14 @@ def test_sigs_compatible(a, b, check_annotations): "a, b, check_annotations", [ param( - lambda posarg, /, *, kwarg2=None, kwarg1=None: ..., - lambda posarg, *, kwarg1=None, kwarg2=None, kwarg3=None: ..., + lambda posarg, /, *, kwarg2=None, kwarg1=None: ..., # noqa: ARG005 + lambda posarg, *, kwarg1=None, kwarg2=None, kwarg3=None: ..., # noqa: ARG005 True, id="one positional only", ), param( - lambda posarg, *, kwarg1=None, kwarg2=None: ..., - lambda posarg, kwarg1=None, kwarg2=None: ..., + lambda posarg, *, kwarg1=None, kwarg2=None: ..., # noqa: ARG005 + lambda posarg, kwarg1=None, kwarg2=None: ..., # noqa: ARG005 True, id="not kwarg only", ), diff --git a/ibis/backends/tests/sql/test_sql.py b/ibis/backends/tests/sql/test_sql.py index 62a7f59593be..8d69484db46e 100644 --- a/ibis/backends/tests/sql/test_sql.py +++ b/ibis/backends/tests/sql/test_sql.py @@ -126,7 +126,7 @@ def test_comparisons(functional_alltypes, opname, snapshot): ] ], ) -def test_binop_parens(snapshot, opname, dtype, associative): +def test_binop_parens(snapshot, opname, dtype): op = getattr(operator, opname) dtypes = [ibis.dtype(d) for d in dtype.split(",")] while len(dtypes) < 3: diff --git a/ibis/backends/tests/test_array.py b/ibis/backends/tests/test_array.py index 0c15bcd0dcd8..65f729fa79ed 100644 --- a/ibis/backends/tests/test_array.py +++ b/ibis/backends/tests/test_array.py @@ -743,7 +743,10 @@ def test_array_filter_with_index(con, input, output, predicate): ) @pytest.mark.parametrize( "predicate", - [lambda x, i: i % 2 == 0, partial(lambda x, y, i: i % 2 == 0, y=1)], + [ + lambda _, i: i % 2 == 0, + partial(lambda _, y, i: i % 2 == 0, y=1), # noqa: ARG005 + ], ids=["lambda", "partial"], ) def test_array_filter_with_index_lambda(con, input, output, predicate): diff --git a/ibis/backends/tests/test_client.py b/ibis/backends/tests/test_client.py index 20726dd8cc55..f2b0c75d050b 100644 --- a/ibis/backends/tests/test_client.py +++ b/ibis/backends/tests/test_client.py @@ -1868,7 +1868,12 @@ def test_identically_named_memtables_cannot_be_joined(con): @pytest.mark.parametrize("i", range(5)) def test_stateful_data_is_loaded_once( - con, data_dir, tmp_path_factory, worker_id, mocker, i + con, + data_dir, + tmp_path_factory, + worker_id, + mocker, + i, # noqa: ARG001 ): TestConf = pytest.importorskip(f"ibis.backends.{con.name}.tests.conftest").TestConf if not TestConf.stateful: diff --git a/ibis/backends/tests/test_impure.py b/ibis/backends/tests/test_impure.py index b6222901db3f..a5ce2f328abe 100644 --- a/ibis/backends/tests/test_impure.py +++ b/ibis/backends/tests/test_impure.py @@ -58,7 +58,7 @@ @ibis.udf.scalar.python(side_effects=True) -def my_random(x: float) -> float: +def my_random(_: float) -> float: # need to make the whole UDF self-contained for postgres to work import random diff --git a/ibis/backends/tests/test_io.py b/ibis/backends/tests/test_io.py index 47996145624c..76778e8dd8f6 100644 --- a/ibis/backends/tests/test_io.py +++ b/ibis/backends/tests/test_io.py @@ -418,7 +418,7 @@ def test_read_json_glob(con, tmp_path, ft_data): ) def test_read_garbage(con, monkeypatch): # monkeypatch to avoid downloading extensions in tests - monkeypatch.setattr(con, "_load_extensions", lambda x: True) + monkeypatch.setattr(con, "_load_extensions", lambda _: True) duckdb = pytest.importorskip("duckdb") with pytest.raises( diff --git a/ibis/backends/tests/test_markers.py b/ibis/backends/tests/test_markers.py index 16de77e9c6c8..f8279c2f7ece 100644 --- a/ibis/backends/tests/test_markers.py +++ b/ibis/backends/tests/test_markers.py @@ -8,60 +8,60 @@ @pytest.mark.notimpl(all_backends) -def test_notimpl(con): +def test_notimpl(con): # noqa: ARG001 raise Exception @pytest.mark.notimpl(all_backends, raises=None) -def test_notimpl_raises_none(con): +def test_notimpl_raises_none(con): # noqa: ARG001 raise Exception @pytest.mark.notimpl(all_backends, raises=(None, None)) -def test_notimpl_raises_none_tuple(con): +def test_notimpl_raises_none_tuple(con): # noqa: ARG001 raise Exception @pytest.mark.notimpl(all_backends, raises=(Exception, None)) -def test_notimpl_raises_tuple_exception_none(con): +def test_notimpl_raises_tuple_exception_none(con): # noqa: ARG001 raise Exception @pytest.mark.notyet(all_backends) -def test_notyet(con): +def test_notyet(con): # noqa: ARG001 raise Exception @pytest.mark.notyet(all_backends, raises=None) -def test_notyet_raises_none(con): +def test_notyet_raises_none(con): # noqa: ARG001 raise Exception @pytest.mark.notyet(all_backends, raises=(None, None)) -def test_notyet_raises_none_tuple(con): +def test_notyet_raises_none_tuple(con): # noqa: ARG001 raise Exception @pytest.mark.notyet(all_backends, raises=(Exception, None)) -def test_notyet_raises_tuple_exception_none(con): +def test_notyet_raises_tuple_exception_none(con): # noqa: ARG001 raise Exception @pytest.mark.never(all_backends, reason="because I said so") -def test_never(con): +def test_never(con): # noqa: ARG001 raise Exception @pytest.mark.never(all_backends, raises=None, reason="because I said so") -def test_never_raises_none(con): +def test_never_raises_none(con): # noqa: ARG001 raise Exception @pytest.mark.never(all_backends, raises=(None, None), reason="because I said so") -def test_never_raises_none_tuple(con): +def test_never_raises_none_tuple(con): # noqa: ARG001 raise Exception @pytest.mark.never(all_backends, raises=(Exception, None), reason="because I said so") -def test_never_raises_tuple_exception_none(con): +def test_never_raises_tuple_exception_none(con): # noqa: ARG001 raise Exception diff --git a/ibis/backends/tests/test_numeric.py b/ibis/backends/tests/test_numeric.py index 8c4c236afa8c..a7a4935cc97f 100644 --- a/ibis/backends/tests/test_numeric.py +++ b/ibis/backends/tests/test_numeric.py @@ -669,29 +669,25 @@ def test_decimal_literal(con, backend, expr, expected_types, expected_result): ], ), param( - lambda t: ibis.literal(1.3), - lambda t: 1.3, + lambda _: ibis.literal(1.3), + lambda _: 1.3, id="float-literal", marks=[ pytest.mark.notimpl(["exasol"], raises=com.OperationNotDefinedError) ], ), + param(lambda _: ibis.literal(np.nan), lambda _: np.nan, id="nan-literal"), param( - lambda t: ibis.literal(np.nan), - lambda t: np.nan, - id="nan-literal", - ), - param( - lambda t: ibis.literal(np.inf), - lambda t: np.inf, + lambda _: ibis.literal(np.inf), + lambda _: np.inf, id="inf-literal", marks=[ pytest.mark.notimpl(["exasol"], raises=com.OperationNotDefinedError) ], ), param( - lambda t: ibis.literal(-np.inf), - lambda t: -np.inf, + lambda _: ibis.literal(-np.inf), + lambda _: -np.inf, id="-inf-literal", marks=[ pytest.mark.notimpl(["exasol"], raises=com.OperationNotDefinedError) @@ -1074,7 +1070,7 @@ def test_complex_math_functions_columns( ("expr_fn", "expected_fn"), [ param( - lambda be, t: t.double_col.round(), + lambda _, t: t.double_col.round(), lambda be, t: be.round(t.double_col), id="round", marks=[ @@ -1087,21 +1083,21 @@ def test_complex_math_functions_columns( ], ), param( - lambda be, t: t.double_col.add(0.05).round(3), + lambda _, t: t.double_col.add(0.05).round(3), lambda be, t: be.round(t.double_col + 0.05, 3), id="round-with-param", ), param( - lambda be, t: ibis.least(t.bigint_col, t.int_col), - lambda be, t: pd.Series(list(map(min, t.bigint_col, t.int_col))), + lambda _, t: ibis.least(t.bigint_col, t.int_col), + lambda _, t: pd.Series(list(map(min, t.bigint_col, t.int_col))), id="least-all-columns", marks=pytest.mark.notimpl( ["datafusion"], raises=com.OperationNotDefinedError ), ), param( - lambda be, t: ibis.least(t.bigint_col, t.int_col, -2), - lambda be, t: pd.Series( + lambda _, t: ibis.least(t.bigint_col, t.int_col, -2), + lambda _, t: pd.Series( list(map(min, t.bigint_col, t.int_col, [-2] * len(t))) ), id="least-scalar", @@ -1110,16 +1106,16 @@ def test_complex_math_functions_columns( ), ), param( - lambda be, t: ibis.greatest(t.bigint_col, t.int_col), - lambda be, t: pd.Series(list(map(max, t.bigint_col, t.int_col))), + lambda _, t: ibis.greatest(t.bigint_col, t.int_col), + lambda _, t: pd.Series(list(map(max, t.bigint_col, t.int_col))), id="greatest-all-columns", marks=pytest.mark.notimpl( ["datafusion"], raises=com.OperationNotDefinedError ), ), param( - lambda be, t: ibis.greatest(t.bigint_col, t.int_col, -2), - lambda be, t: pd.Series( + lambda _, t: ibis.greatest(t.bigint_col, t.int_col, -2), + lambda _, t: pd.Series( list(map(max, t.bigint_col, t.int_col, [-2] * len(t))) ), id="greatest-scalar", diff --git a/ibis/backends/tests/test_string.py b/ibis/backends/tests/test_string.py index fc5921ddfe49..7a3e8a048ee6 100644 --- a/ibis/backends/tests/test_string.py +++ b/ibis/backends/tests/test_string.py @@ -1187,7 +1187,7 @@ def string_temp_table(backend, con): ), param( lambda t: t.string_col.find_in_set(["aBc", "123"]), - lambda t: pd.Series([-1, -1, -1, 1, 0, -1, -1], name="tmp"), + lambda _: pd.Series([-1, -1, -1, 1, 0, -1, -1], name="tmp"), id="find_in_set", marks=[ pytest.mark.notyet( @@ -1216,7 +1216,7 @@ def string_temp_table(backend, con): ), param( lambda t: t.string_col.find_in_set(["abc, 123"]), - lambda t: pd.Series([-1, -1, -1, -1, -1, -1, -1], name="tmp"), + lambda _: pd.Series([-1, -1, -1, -1, -1, -1, -1], name="tmp"), id="find_in_set_w_comma", marks=[ pytest.mark.notyet( diff --git a/ibis/backends/trino/tests/conftest.py b/ibis/backends/trino/tests/conftest.py index b80121f6ecf4..4e6538306247 100644 --- a/ibis/backends/trino/tests/conftest.py +++ b/ibis/backends/trino/tests/conftest.py @@ -135,7 +135,7 @@ def test_files(self) -> Iterable[Path]: return self.data_dir.joinpath("parquet").glob("*.parquet") @staticmethod - def connect(*, tmpdir, worker_id, **kw): + def connect(*, tmpdir, worker_id, **kw): # noqa: ARG004 return ibis.trino.connect( host=TRINO_HOST, port=TRINO_PORT, diff --git a/ibis/common/tests/test_annotations.py b/ibis/common/tests/test_annotations.py index 92bc10a2e6e3..dc06e7da546b 100644 --- a/ibis/common/tests/test_annotations.py +++ b/ibis/common/tests/test_annotations.py @@ -81,7 +81,7 @@ def test_annotations_are_not_hashable(): def test_default_argument(): - annotation = Argument(pattern=lambda x, context: int(x), default=3) + annotation = Argument(pattern=lambda x, *_, **__: int(x), default=3) assert annotation.pattern.match(1, {}) == 1 @@ -122,7 +122,7 @@ class Foo: assert field.get_default("b", Foo) == 20 - field2 = Attribute(pattern=lambda x, this: str(x), default=lambda self: self.a) + field2 = Attribute(pattern=lambda x, *_, **__: str(x), default=lambda self: self.a) assert field2.has_default() assert field != field2 assert field2.get_default("b", Foo) == "10" @@ -146,11 +146,11 @@ def fn(x, this): assert op.annotation.pattern.match(None, {"other": 1}) is None with pytest.raises(TypeError, match="annotation must be an instance of Argument"): - Parameter.from_argument("wrong", annotation=Attribute(lambda x, context: x)) + Parameter.from_argument("wrong", annotation=Attribute(lambda x, *_, **__: x)) def test_signature(): - def to_int(x, this): + def to_int(x, *_, **__): return int(x) def add_other(x, this): @@ -212,7 +212,7 @@ def test(a: int, b: int, *args: int): ... assert kwargs == {} -def test_signature_from_callable_with_positional_only_arguments(snapshot): +def test_signature_from_callable_with_positional_only_arguments(): def test(a: int, b: int, /, c: int = 1): ... sig = Signature.from_callable(test) @@ -263,7 +263,7 @@ def test(a: int, b: int, *, c: float, d: float = 0.0): ... def test_signature_unbind(): - def to_int(x, this): + def to_int(x, *_, **__): return int(x) def add_other(x, this): @@ -352,7 +352,7 @@ def test_ok(a: int, b: int, c: int = 1) -> int: return a + b + c @annotated - def test_wrong(a: int, b: int, c: int = 1) -> int: + def test_wrong(a: int, b: int, c: int = 1) -> int: # noqa: ARG001 return "invalid result" assert test_ok(2, 3) == 6 @@ -392,7 +392,7 @@ def test(a: int, b: int, c: int = 1): @pattern -def short_str(x, this): +def short_str(x, *_, **__): if len(x) > 3: return x else: @@ -400,7 +400,7 @@ def short_str(x, this): @pattern -def endswith_d(x, this): +def endswith_d(x, *_, **__): if x.endswith("d"): return x else: diff --git a/ibis/common/tests/test_bases.py b/ibis/common/tests/test_bases.py index 68846f5f167a..86722d4cd561 100644 --- a/ibis/common/tests/test_bases.py +++ b/ibis/common/tests/test_bases.py @@ -116,7 +116,7 @@ def cache(): assert not cache -def test_comparable_basic(cache): +def test_comparable_basic(): a = Node(name="a") b = Node(name="a") c = Node(name="a") diff --git a/ibis/common/tests/test_deferred.py b/ibis/common/tests/test_deferred.py index e3600face7eb..82d1b7a867e6 100644 --- a/ibis/common/tests/test_deferred.py +++ b/ibis/common/tests/test_deferred.py @@ -584,7 +584,7 @@ def test_deferred_is_immutable(): _.a = 1 -def test_deferred_namespace(table): +def test_deferred_namespace(): ns = Namespace(deferred, module=__name__) assert isinstance(ns.ColumnMock, Deferred) diff --git a/ibis/common/tests/test_dispatch.py b/ibis/common/tests/test_dispatch.py index 4b3a34ff5b7c..6fd2877397ce 100644 --- a/ibis/common/tests/test_dispatch.py +++ b/ibis/common/tests/test_dispatch.py @@ -8,7 +8,7 @@ def test_lazy_singledispatch(): @lazy_singledispatch - def foo(x): + def foo(_): """A docstring.""" return "base result" @@ -61,7 +61,7 @@ def foo(a): return a @foo.register("decimal.Decimal") - def inc(a): + def _(a): return a + 1 assert foo(1) == 1 @@ -76,15 +76,15 @@ class Subclass2(decimal.Decimal): pass @lazy_singledispatch - def foo(a): + def foo(_): return "base call" @foo.register(Subclass2) - def _(a): + def _(_): return "eager call" @foo.register("decimal.Decimal") - def _(a): + def _(_): return "lazy call" assert foo(1) == "base call" @@ -99,19 +99,19 @@ class mydict(dict): pass @lazy_singledispatch - def foo(a): + def foo(_): return "base" @foo.register(collections.abc.Mapping) - def _(a): + def _(_): return "mapping" @foo.register(mydict) - def _(a): + def _(_): return "mydict" @foo.register(collections.abc.Callable) - def _(a): + def _(_): return "callable" assert foo(1) == "base" diff --git a/ibis/common/tests/test_egraph.py b/ibis/common/tests/test_egraph.py index 98fcd04bf1ce..1d1db469b8dd 100644 --- a/ibis/common/tests/test_egraph.py +++ b/ibis/common/tests/test_egraph.py @@ -443,7 +443,7 @@ def test_egraph_rewrite_to_pattern(): def test_egraph_rewrite_dynamic(): - def applier(egraph, match, a, mul, times): + def applier(egraph, match, a, *_): # noqa: ARG001 return ENode(ops.Add, (a, a)) node = (one * 2).op() @@ -518,7 +518,7 @@ def test_math_associate_adds(benchmark): benchmark(is_equal, expr_a, expr_b, math_rules, iters=500) -def replace_add(egraph, enode, **kwargs): +def replace_add(egraph, enode, **_): node = egraph.extract(enode) enode = egraph.add(node) return enode diff --git a/ibis/common/tests/test_graph.py b/ibis/common/tests/test_graph.py index 1408b5cdfeba..e4c1fd1aac24 100644 --- a/ibis/common/tests/test_graph.py +++ b/ibis/common/tests/test_graph.py @@ -373,7 +373,7 @@ def test_coerce_finder(): def test_coerce_replacer(): - r = _coerce_replacer(lambda x, children: D if children else C) + r = _coerce_replacer(lambda _, children: D if children else C) assert r(C, {"children": []}) is D assert r(C, None) is C @@ -475,7 +475,7 @@ def test_map_clear(): X = MyNode(name="X", children=[Z, Y]) result_sequence = {} - def record_result_keys(node, results, **kwargs): + def record_result_keys(node, results, **_): result_sequence[node] = tuple(results.keys()) return node diff --git a/ibis/common/tests/test_patterns.py b/ibis/common/tests/test_patterns.py index f4abc9fc8382..380cf756a846 100644 --- a/ibis/common/tests/test_patterns.py +++ b/ibis/common/tests/test_patterns.py @@ -74,7 +74,7 @@ class Double(Pattern): - def match(self, value, *, context): + def match(self, value, **_): return value * 2 def __eq__(self, other): @@ -90,7 +90,7 @@ class Min(Pattern): def __init__(self, min): self.min = min - def match(self, value, context): + def match(self, value, *_, **__): if value >= self.min: return value else: @@ -679,7 +679,7 @@ def func(a, b): def func_with_args(a, b, *args): return sum((a, b) + args) - def func_with_kwargs(a, b, c=1, **kwargs): + def func_with_kwargs(a, b, c=1, **_): return str(a) + b + str(c) def func_with_optional_keyword_only_kwargs(a, *, c=1): @@ -1083,7 +1083,7 @@ def test_various_not_matching_patterns(pattern, value): @pattern -def endswith_d(s, ctx): +def endswith_d(s, *_, **__): if not s.endswith("d"): return NoMatch return s diff --git a/ibis/expr/tests/test_format.py b/ibis/expr/tests/test_format.py index 855b295dc4b5..fd590e6ff750 100644 --- a/ibis/expr/tests/test_format.py +++ b/ibis/expr/tests/test_format.py @@ -421,7 +421,7 @@ def values(self): snapshot.assert_match(result, "repr.txt") -def test_format_new_value_operation(alltypes, snapshot): +def test_format_new_value_operation(alltypes): class Inc(ops.Value): arg: ops.Value diff --git a/ibis/expr/tests/test_reductions.py b/ibis/expr/tests/test_reductions.py index adfcfb95008a..c1ffe04ff56e 100644 --- a/ibis/expr/tests/test_reductions.py +++ b/ibis/expr/tests/test_reductions.py @@ -80,15 +80,9 @@ @pytest.mark.parametrize( "cond", [ - pytest.param(lambda t: None, id="no_cond"), - pytest.param( - lambda t: t.string_col.isin(["1", "7"]), - id="is_in", - ), - pytest.param( - lambda t: _.string_col.isin(["1", "7"]), - id="is_in_deferred", - ), + pytest.param(lambda _: None, id="no_cond"), + pytest.param(lambda t: t.string_col.isin(["1", "7"]), id="is_in"), + pytest.param(lambda _: _.string_col.isin(["1", "7"]), id="is_in_deferred"), ], ) def test_reduction_methods(fn, operation, cond): diff --git a/ibis/tests/expr/mocks.py b/ibis/tests/expr/mocks.py index 2d7bed3b85af..8eb70fc462a6 100644 --- a/ibis/tests/expr/mocks.py +++ b/ibis/tests/expr/mocks.py @@ -48,7 +48,7 @@ def _register_in_memory_table(self, op: ops.InMemoryTable) -> None: def _finalize_memtable(self, name: str) -> None: pass - def table(self, name, **kwargs): + def table(self, name, **_): schema = self.get_schema(name) node = ops.DatabaseTable(source=self, name=name, schema=schema) return node.to_expr() @@ -96,7 +96,7 @@ def _clean_up_cached_table(self, _): def _get_schema_using_query(self, query): return self.sql_query_schemas[query] - def _get_sql_string_view_schema(self, name, table, query): + def _get_sql_string_view_schema(self, name, table, query): # noqa: ARG002 return self.sql_query_schemas[query] @contextlib.contextmanager diff --git a/ibis/tests/expr/test_case.py b/ibis/tests/expr/test_case.py index 351e161f7d8b..f0122026ae52 100644 --- a/ibis/tests/expr/test_case.py +++ b/ibis/tests/expr/test_case.py @@ -170,7 +170,7 @@ def test_case_mixed_type(): assert result["label"].type().equals(dt.string) -def test_err_on_bad_args(table): +def test_err_on_bad_args(): with pytest.raises(ValueError): ibis.cases((True,)) with pytest.raises(ValueError): diff --git a/ibis/tests/expr/test_table.py b/ibis/tests/expr/test_table.py index 5d4a4d9d70f6..9ff389911150 100644 --- a/ibis/tests/expr/test_table.py +++ b/ibis/tests/expr/test_table.py @@ -201,7 +201,7 @@ def test_projection_sort_keys_errors(table): table.mutate(new=table.c.asc()) -def test_projection_invalid_root(table): +def test_projection_invalid_root(): schema1 = {"foo": "double", "bar": "int32"} left = api.table(schema1, name="foo") @@ -1100,7 +1100,7 @@ def test_self_join_no_view_convenience(table): assert result.columns == expected_cols -def test_join_project_after(table): +def test_join_project_after(): # e.g. # # SELECT L.foo, L.bar, R.baz, R.qux @@ -1127,7 +1127,7 @@ def test_join_project_after(table): assert projected.schema().names == ("key2", "stuff", "key1") -def test_semi_join_schema(table): +def test_semi_join_schema(): # A left semi join discards the schema of the right table table1 = ibis.table([("key1", "string"), ("value1", "double")]) table2 = ibis.table([("key2", "string"), ("stuff", "double")]) @@ -1231,12 +1231,12 @@ def test_inner_join_overlapping_column_names(): "key_maker", [ lambda t1, t2: t1.foo_id == t2.foo_id, - lambda t1, t2: [("foo_id", "foo_id")], + lambda *__: [("foo_id", "foo_id")], lambda t1, t2: [(t1.foo_id, t2.foo_id)], - lambda t1, t2: [(_.foo_id, _.foo_id)], - lambda t1, t2: [(t1.foo_id, _.foo_id)], + lambda *__: [(_.foo_id, _.foo_id)], + lambda t1, __: [(t1.foo_id, _.foo_id)], lambda t1, t2: [(t1[2], t2[0])], # foo_id is 2nd in t1, 0th in t2 - lambda t1, t2: [(lambda t: t.foo_id, lambda t: t.foo_id)], + lambda *_: [(lambda t: t.foo_id, lambda t: t.foo_id)], ], ) def test_join_key_alternatives(con, key_maker): @@ -1303,7 +1303,7 @@ def test_join_non_boolean_expr(con): t1.inner_join(t2, [predicate]) -def test_unravel_compound_equijoin(table): +def test_unravel_compound_equijoin(_): t1 = ibis.table( [ ("key1", "string"), @@ -2103,7 +2103,7 @@ def eq(left, right): # no args assert t.bind() == () - def utter_failure(x): + def utter_failure(_): raise ValueError("¡moo!") with pytest.raises(ValueError, match="¡moo!"): diff --git a/ibis/tests/expr/test_temporal.py b/ibis/tests/expr/test_temporal.py index 9daf487abf5f..902ae71128f5 100644 --- a/ibis/tests/expr/test_temporal.py +++ b/ibis/tests/expr/test_temporal.py @@ -671,7 +671,7 @@ def test_interval_comparisons(unit, operands, operator, table): @pytest.mark.parametrize( "operands", [ - lambda t: (api.date("2016-01-01"), api.date("2016-02-02")), + lambda _: (api.date("2016-01-01"), api.date("2016-02-02")), lambda t: (t.j, api.date("2016-01-01")), lambda t: (api.date("2016-01-01"), t.j), lambda t: (t.j, t.i.date()), @@ -748,7 +748,7 @@ def test_interval_column_name(table): @pytest.mark.parametrize( "operand", - [lambda t: api.timestamp(datetime.datetime.now()), lambda t: t.i], + [lambda _: api.timestamp(datetime.datetime.now()), lambda t: t.i], ids=["column", "literal"], ) @pytest.mark.parametrize( @@ -806,7 +806,7 @@ def test_timestamp_truncate(table, operand, unit): assert isinstance(expr.op(), ops.TimestampTruncate) -@pytest.mark.parametrize("operand", [lambda t: api.date("2018-01-01"), lambda t: t.j]) +@pytest.mark.parametrize("operand", [lambda _: api.date("2018-01-01"), lambda t: t.j]) @pytest.mark.parametrize("unit", ["Y", "Q", "M", "D", "W"]) def test_date_truncate(table, operand, unit): expr = operand(table).truncate(unit) @@ -814,7 +814,7 @@ def test_date_truncate(table, operand, unit): assert isinstance(expr.op(), ops.DateTruncate) -@pytest.mark.parametrize("operand", [lambda t: api.time("18:00"), lambda t: t.k]) +@pytest.mark.parametrize("operand", [lambda _: api.time("18:00"), lambda t: t.k]) @pytest.mark.parametrize("unit", ["h", "m", "s", "ms", "us", "ns"]) def test_time_truncate(table, operand, unit): expr = operand(table).truncate(unit) diff --git a/ibis/tests/expr/test_timestamp.py b/ibis/tests/expr/test_timestamp.py index d175afe6e440..831add34a8fd 100644 --- a/ibis/tests/expr/test_timestamp.py +++ b/ibis/tests/expr/test_timestamp.py @@ -134,9 +134,7 @@ def test_timestamp_field_access_on_date( ("millisecond", ops.ExtractMillisecond, ir.IntegerColumn), ], ) -def test_timestamp_field_access_on_date_failure( - field, expected_operation, expected_type, alltypes -): +def test_timestamp_field_access_on_date_failure(field, alltypes): time_col = alltypes.i.date() with pytest.raises(AttributeError): getattr(time_col, field) diff --git a/ibis/tests/expr/test_udf.py b/ibis/tests/expr/test_udf.py index 935394e1676d..e6ed02f511d6 100644 --- a/ibis/tests/expr/test_udf.py +++ b/ibis/tests/expr/test_udf.py @@ -33,7 +33,7 @@ def table(): ) def test_vectorized_udf_operations(table, klass, output_type): udf = klass( - func=lambda a, b, c: a, + func=lambda a, *_: a, func_args=[table.a, table.b, table.c], input_type=[dt.int8(), dt.string(), dt.boolean()], return_type=dt.int8(), @@ -58,7 +58,7 @@ def test_vectorized_udf_operations(table, klass, output_type): with pytest.raises(ValidationError): # scalar type instead of column type klass( - func=lambda a, b, c: a, + func=lambda a, *_: a, func_args=[ibis.literal(1), table.b, table.c], input_type=[dt.int8(), dt.string(), dt.boolean()], return_type=dt.int8(), @@ -67,7 +67,7 @@ def test_vectorized_udf_operations(table, klass, output_type): with pytest.raises(ValidationError): # wrong input type klass( - func=lambda a, b, c: a, + func=lambda a, *_: a, func_args=[ibis.literal(1), table.b, table.c], input_type="int8", return_type=dt.int8(), @@ -76,7 +76,7 @@ def test_vectorized_udf_operations(table, klass, output_type): with pytest.raises(ValidationError): # wrong return type klass( - func=lambda a, b, c: a, + func=lambda a, *_: a, func_args=[ibis.literal(1), table.b, table.c], input_type=[dt.int8(), dt.string(), dt.boolean()], return_type=table, diff --git a/ibis/tests/expr/test_window_frames.py b/ibis/tests/expr/test_window_frames.py index 7477544f3da9..c2242c1fc914 100644 --- a/ibis/tests/expr/test_window_frames.py +++ b/ibis/tests/expr/test_window_frames.py @@ -548,7 +548,7 @@ def test_windowization_wraps_reduction_inside_a_nested_value_expression(t): assert expr.op() == expected -def test_group_by_with_window_function_preserves_range(alltypes): +def test_group_by_with_window_function_preserves_range(): t = ibis.table(dict(one="string", two="double", three="int32"), name="my_data") w = ibis.cumulative_window(order_by=t.one) expr = t.group_by(t.three).mutate(four=t.two.sum().over(w)) diff --git a/pyproject.toml b/pyproject.toml index 81ec5c86cda1..6c2f6cf861e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -527,6 +527,7 @@ select = [ "W", # pycodestyle "YTT", # flake8-2020 "S", # flake8-bandit + "ARG", ] ignore = [ "B028", # required stacklevel argument to warn @@ -602,6 +603,7 @@ required-imports = ["from __future__ import annotations"] "T201", ] # prints output using `print` "docs/**/{datafusion,polars}_*.py" = ["T201"] # prints output using `print` +"!**/test*.py" = ["ARG"] # check for unused arguments in testing [tool.ruff.format] docstring-code-format = true From e6202472f360992c3e883e2f5cca8ad6a0a7011e Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Wed, 23 Apr 2025 09:09:45 -0400 Subject: [PATCH 2/5] chore: remove more unused fixtures --- ibis/backends/tests/sql/test_sql.py | 50 ++++++++++++++--------------- ibis/tests/expr/test_timestamp.py | 9 +----- 2 files changed, 26 insertions(+), 33 deletions(-) diff --git a/ibis/backends/tests/sql/test_sql.py b/ibis/backends/tests/sql/test_sql.py index 8d69484db46e..f635da1c17a4 100644 --- a/ibis/backends/tests/sql/test_sql.py +++ b/ibis/backends/tests/sql/test_sql.py @@ -90,45 +90,45 @@ def test_comparisons(functional_alltypes, opname, snapshot): @pytest.mark.parametrize( - "opname, dtype, associative", + ("opname", "dtype"), [ param(*v, id=f"{v[0]}-{v[1]}") for v in [ # Numeric - ("add", "int8", True), - ("mul", "int8", True), - ("sub", "int8", False), - ("truediv", "int8", False), - ("mod", "int8", False), - ("pow", "int8", False), - ("and_", "int8", True), - ("or_", "int8", True), - ("xor", "int8", True), - ("lshift", "int8", False), - ("rshift", "int8", False), + ("add", "int8"), + ("mul", "int8"), + ("sub", "int8"), + ("truediv", "int8"), + ("mod", "int8"), + ("pow", "int8"), + ("and_", "int8"), + ("or_", "int8"), + ("xor", "int8"), + ("lshift", "int8"), + ("rshift", "int8"), # Logical - ("and_", "bool", True), - ("or_", "bool", True), - ("xor", "bool", True), + ("and_", "bool"), + ("or_", "bool"), + ("xor", "bool"), # Date - ("add", "date,interval('D')", True), - ("sub", "date,interval('D')", False), + ("add", "date,interval('D')"), + ("sub", "date,interval('D')"), # Time - ("add", "time,interval", True), - ("sub", "time,interval", False), + ("add", "time,interval"), + ("sub", "time,interval"), # Timestamp - ("add", "timestamp,interval", True), - ("sub", "timestamp,interval", False), + ("add", "timestamp,interval"), + ("sub", "timestamp,interval"), # Interval - ("add", "interval", True), - ("sub", "interval", False), - ("mul", "interval,int8", True), + ("add", "interval"), + ("sub", "interval"), + ("mul", "interval,int8"), ] ], ) def test_binop_parens(snapshot, opname, dtype): op = getattr(operator, opname) - dtypes = [ibis.dtype(d) for d in dtype.split(",")] + dtypes = list(map(ibis.dtype, dtype.split(","))) while len(dtypes) < 3: dtypes.append(dtypes[-1]) # repeat last dtype diff --git a/ibis/tests/expr/test_timestamp.py b/ibis/tests/expr/test_timestamp.py index 831add34a8fd..186a4d9aea02 100644 --- a/ibis/tests/expr/test_timestamp.py +++ b/ibis/tests/expr/test_timestamp.py @@ -125,14 +125,7 @@ def test_timestamp_field_access_on_date( @pytest.mark.parametrize( - ("field", "expected_operation", "expected_type"), - [ - ("hour", ops.ExtractHour, ir.IntegerColumn), - ("minute", ops.ExtractMinute, ir.IntegerColumn), - ("second", ops.ExtractSecond, ir.IntegerColumn), - ("microsecond", ops.ExtractMicrosecond, ir.IntegerColumn), - ("millisecond", ops.ExtractMillisecond, ir.IntegerColumn), - ], + "field", ["hour", "minute", "second", "microsecond", "millisecond"] ) def test_timestamp_field_access_on_date_failure(field, alltypes): time_col = alltypes.i.date() From baa31e424e1119355ee0b895c12988d308ce86fe Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Wed, 23 Apr 2025 09:22:14 -0400 Subject: [PATCH 3/5] chore: remove more unused fixtures --- ibis/tests/expr/test_table.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibis/tests/expr/test_table.py b/ibis/tests/expr/test_table.py index 9ff389911150..6dc6a8ceb344 100644 --- a/ibis/tests/expr/test_table.py +++ b/ibis/tests/expr/test_table.py @@ -1303,7 +1303,7 @@ def test_join_non_boolean_expr(con): t1.inner_join(t2, [predicate]) -def test_unravel_compound_equijoin(_): +def test_unravel_compound_equijoin(): t1 = ibis.table( [ ("key1", "string"), From 8ff8ce1d72e19f5c9e9cdeea3d2da42bdb92ac34 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Wed, 23 Apr 2025 09:23:00 -0400 Subject: [PATCH 4/5] chore: remove more unused fixtures --- ibis/common/tests/test_egraph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibis/common/tests/test_egraph.py b/ibis/common/tests/test_egraph.py index 1d1db469b8dd..bf0057678d29 100644 --- a/ibis/common/tests/test_egraph.py +++ b/ibis/common/tests/test_egraph.py @@ -443,7 +443,7 @@ def test_egraph_rewrite_to_pattern(): def test_egraph_rewrite_dynamic(): - def applier(egraph, match, a, *_): # noqa: ARG001 + def applier(egraph, match, a, *_, **__): # noqa: ARG001 return ENode(ops.Add, (a, a)) node = (one * 2).op() From 3190f6ecab88d42240e4191c12e2480d7d741bcd Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Wed, 23 Apr 2025 09:25:41 -0400 Subject: [PATCH 5/5] chore: remove more unused fixtures --- .../unit/udf/snapshots/test_core/test_scope_with_while/out.js | 2 +- .../unit/udf/snapshots/test_core/test_set_to_object/out.js | 2 +- .../tests/unit/udf/snapshots/test_core/test_setitem/out.js | 2 +- .../tests/unit/udf/snapshots/test_core/test_yield/out.js | 2 +- ibis/backends/bigquery/tests/unit/udf/test_usage.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ibis/backends/bigquery/tests/unit/udf/snapshots/test_core/test_scope_with_while/out.js b/ibis/backends/bigquery/tests/unit/udf/snapshots/test_core/test_scope_with_while/out.js index a4e660c21799..04022d0dd208 100644 --- a/ibis/backends/bigquery/tests/unit/udf/snapshots/test_core/test_scope_with_while/out.js +++ b/ibis/backends/bigquery/tests/unit/udf/snapshots/test_core/test_scope_with_while/out.js @@ -1,5 +1,5 @@ function f() { - class Foo { + class _ { do_stuff() { while (true) { let i = 1; diff --git a/ibis/backends/bigquery/tests/unit/udf/snapshots/test_core/test_set_to_object/out.js b/ibis/backends/bigquery/tests/unit/udf/snapshots/test_core/test_set_to_object/out.js index 8b84601b9637..bb223a81b043 100644 --- a/ibis/backends/bigquery/tests/unit/udf/snapshots/test_core/test_set_to_object/out.js +++ b/ibis/backends/bigquery/tests/unit/udf/snapshots/test_core/test_set_to_object/out.js @@ -1,4 +1,4 @@ -function f(a) { +function f(_) { let x = (new Set()); let y = 1; x.add(y); diff --git a/ibis/backends/bigquery/tests/unit/udf/snapshots/test_core/test_setitem/out.js b/ibis/backends/bigquery/tests/unit/udf/snapshots/test_core/test_setitem/out.js index 94ce195b28fc..c2dbe8a9bc7a 100644 --- a/ibis/backends/bigquery/tests/unit/udf/snapshots/test_core/test_setitem/out.js +++ b/ibis/backends/bigquery/tests/unit/udf/snapshots/test_core/test_setitem/out.js @@ -1,4 +1,4 @@ -function f(a) { +function f(_) { let x = {}; let y = '2'; x[y] = y; diff --git a/ibis/backends/bigquery/tests/unit/udf/snapshots/test_core/test_yield/out.js b/ibis/backends/bigquery/tests/unit/udf/snapshots/test_core/test_yield/out.js index 26798d88f4d3..08d463cef9f0 100644 --- a/ibis/backends/bigquery/tests/unit/udf/snapshots/test_core/test_yield/out.js +++ b/ibis/backends/bigquery/tests/unit/udf/snapshots/test_core/test_yield/out.js @@ -1,3 +1,3 @@ -function* f(a) { +function* f(_) { yield* [1, 2, 3]; } \ No newline at end of file diff --git a/ibis/backends/bigquery/tests/unit/udf/test_usage.py b/ibis/backends/bigquery/tests/unit/udf/test_usage.py index ad92703393f6..fa14366bb757 100644 --- a/ibis/backends/bigquery/tests/unit/udf/test_usage.py +++ b/ibis/backends/bigquery/tests/unit/udf/test_usage.py @@ -66,7 +66,7 @@ def my_len(s: str) -> float: def test_udf_int64(argument_type, return_type): # invalid argument type, valid return type @udf.scalar.python(signature=((argument_type,), return_type)) - def my_func(_): + def my_func(_x): return 1 expr = my_func(None)