diff --git a/docs/_renderer.py b/docs/_renderer.py index 79cd5c146402..d50819eac694 100644 --- a/docs/_renderer.py +++ b/docs/_renderer.py @@ -61,9 +61,9 @@ def render(self, el: qd.ast.ExampleCode) -> str: if expect_failure in first or any( expect_failure in line for line in rest ): - assert ( - start and end - ), "expected failure should never occur alongside a skipped doctest example" + assert start and end, ( + "expected failure should never occur alongside a skipped doctest example" + ) result.append("#| error: true") # remove the quartodoc markers from the rendered code diff --git a/ibis/backends/clickhouse/tests/test_client.py b/ibis/backends/clickhouse/tests/test_client.py index 5cef7b9e3630..723ed0b6afc7 100644 --- a/ibis/backends/clickhouse/tests/test_client.py +++ b/ibis/backends/clickhouse/tests/test_client.py @@ -369,7 +369,7 @@ def test_create_table_no_syntax_error(con): def test_password_with_bracket(): - password = f'{os.environ.get("IBIS_TEST_CLICKHOUSE_PASSWORD", "")}[]' + password = f"{os.environ.get('IBIS_TEST_CLICKHOUSE_PASSWORD', '')}[]" quoted_pass = quote_plus(password) host = os.environ.get("IBIS_TEST_CLICKHOUSE_HOST", "localhost") user = os.environ.get("IBIS_TEST_CLICKHOUSE_USER", "default") diff --git a/ibis/backends/duckdb/tests/conftest.py b/ibis/backends/duckdb/tests/conftest.py index d398b550f199..629cfee2c9d1 100644 --- a/ibis/backends/duckdb/tests/conftest.py +++ b/ibis/backends/duckdb/tests/conftest.py @@ -66,7 +66,7 @@ def ddl_script(self) -> Iterator[str]: yield ( f""" CREATE OR REPLACE TABLE {table} AS - SELECT * FROM read_parquet('{parquet_dir / f'{table}.parquet'}') + SELECT * FROM read_parquet('{parquet_dir / f"{table}.parquet"}') """ ) if not SANDBOXED: @@ -74,7 +74,7 @@ def ddl_script(self) -> Iterator[str]: yield ( f""" CREATE OR REPLACE TABLE {table} AS - SELECT * FROM st_read('{geojson_dir / f'{table}.geojson'}') + SELECT * FROM st_read('{geojson_dir / f"{table}.geojson"}') """ ) for table in TEST_TABLE_GEO_PARQUET: @@ -82,7 +82,7 @@ def ddl_script(self) -> Iterator[str]: yield ( f""" CREATE OR REPLACE TABLE {table} AS - SELECT * FROM read_parquet('{parquet_dir / f'{table}.parquet'}') + SELECT * FROM read_parquet('{parquet_dir / f"{table}.parquet"}') """ ) yield ( diff --git a/ibis/backends/impala/__init__.py b/ibis/backends/impala/__init__.py index aefa5840cafb..339fb08ab737 100644 --- a/ibis/backends/impala/__init__.py +++ b/ibis/backends/impala/__init__.py @@ -341,8 +341,7 @@ def drop_database(self, name, force=False): ) elif tables or udfs or udas: raise com.IntegrityError( - f"Database {name} must be empty before " - "being dropped, or set force=True" + f"Database {name} must be empty before being dropped, or set force=True" ) statement = ddl.DropDatabase(name, must_exist=not force) self._safe_exec_sql(statement) diff --git a/ibis/backends/impala/tests/test_ddl.py b/ibis/backends/impala/tests/test_ddl.py index fc168b53f691..a89609d6a4a6 100644 --- a/ibis/backends/impala/tests/test_ddl.py +++ b/ibis/backends/impala/tests/test_ddl.py @@ -15,11 +15,11 @@ pytest.importorskip("impala") -from impala.error import HiveServer2Error # noqa: E402 +from impala.error import HiveServer2Error @pytest.fixture -def temp_view(con) -> str: +def temp_view(con): name = util.gen_name("view") yield name con.drop_view(name, force=True) diff --git a/ibis/backends/impala/tests/test_exprs.py b/ibis/backends/impala/tests/test_exprs.py index f700ec5908be..0e8bf180ed81 100644 --- a/ibis/backends/impala/tests/test_exprs.py +++ b/ibis/backends/impala/tests/test_exprs.py @@ -148,9 +148,9 @@ def _check_impala_output_types_match(con, table): for n, left_ty, right_ty in zip( left_schema.names, left_schema.types, right_schema.types ): - assert ( - left_ty == right_ty - ), f"Value for {n} had left type {left_ty} and right type {right_ty}\nquery:\n{query}" + assert left_ty == right_ty, ( + f"Value for {n} had left type {left_ty} and right type {right_ty}\nquery:\n{query}" + ) @pytest.mark.parametrize( diff --git a/ibis/backends/impala/tests/test_parquet_ddl.py b/ibis/backends/impala/tests/test_parquet_ddl.py index c67fe383d16e..0494e8254b4f 100644 --- a/ibis/backends/impala/tests/test_parquet_ddl.py +++ b/ibis/backends/impala/tests/test_parquet_ddl.py @@ -9,7 +9,7 @@ pytest.importorskip("impala") -from impala.error import HiveServer2Error # noqa: E402 +from impala.error import HiveServer2Error def test_parquet_file_with_name(con, test_data_dir, temp_table): diff --git a/ibis/backends/impala/tests/test_partition.py b/ibis/backends/impala/tests/test_partition.py index ab6ff1673b25..2b40603e7664 100644 --- a/ibis/backends/impala/tests/test_partition.py +++ b/ibis/backends/impala/tests/test_partition.py @@ -10,7 +10,7 @@ pytest.importorskip("impala") -from impala.error import Error as ImpylaError # noqa: E402 +from impala.error import Error as ImpylaError @pytest.fixture diff --git a/ibis/backends/sql/compilers/base.py b/ibis/backends/sql/compilers/base.py index 16741aaada48..a86e3013e359 100644 --- a/ibis/backends/sql/compilers/base.py +++ b/ibis/backends/sql/compilers/base.py @@ -205,9 +205,9 @@ def array(self, *args: Any) -> sge.Array: first, *rest = args if isinstance(first, sge.Select): - assert ( - not rest - ), "only one argument allowed when `first` is a select statement" + assert not rest, ( + "only one argument allowed when `first` is a select statement" + ) return sge.Array(expressions=list(map(sge.convert, (first, *rest)))) diff --git a/ibis/backends/sql/compilers/bigquery/udf/core.py b/ibis/backends/sql/compilers/bigquery/udf/core.py index ead41cfa8cc4..7db3af33efd9 100644 --- a/ibis/backends/sql/compilers/bigquery/udf/core.py +++ b/ibis/backends/sql/compilers/bigquery/udf/core.py @@ -283,9 +283,9 @@ def visit_NameConstant(self, node): return "true" elif value is False: return "false" - assert ( - value is None - ), f"value is not True and is not False, must be None, got {value}" + assert value is None, ( + f"value is not True and is not False, must be None, got {value}" + ) return "null" def visit_Str(self, node): diff --git a/ibis/backends/sql/compilers/pyspark.py b/ibis/backends/sql/compilers/pyspark.py index e718a9a39924..3c3bef5a1d72 100644 --- a/ibis/backends/sql/compilers/pyspark.py +++ b/ibis/backends/sql/compilers/pyspark.py @@ -251,8 +251,7 @@ def visit_LastValue(self, op, *, arg): def visit_First(self, op, *, arg, where, order_by, include_null): if where is not None and include_null: raise com.UnsupportedOperationError( - "Combining `include_null=True` and `where` is not supported " - "by pyspark" + "Combining `include_null=True` and `where` is not supported by pyspark" ) out = self.agg.first(arg, where=where, order_by=order_by) if not include_null: @@ -262,8 +261,7 @@ def visit_First(self, op, *, arg, where, order_by, include_null): def visit_Last(self, op, *, arg, where, order_by, include_null): if where is not None and include_null: raise com.UnsupportedOperationError( - "Combining `include_null=True` and `where` is not supported " - "by pyspark" + "Combining `include_null=True` and `where` is not supported by pyspark" ) out = self.agg.last(arg, where=where, order_by=order_by) if not include_null: diff --git a/ibis/backends/sql/compilers/snowflake.py b/ibis/backends/sql/compilers/snowflake.py index aa48a01ad115..7cdc980752fe 100644 --- a/ibis/backends/sql/compilers/snowflake.py +++ b/ibis/backends/sql/compilers/snowflake.py @@ -847,9 +847,9 @@ def visit_ArrayFilter(self, op, *, arg, param, body, index): ) def visit_JoinLink(self, op, *, how, table, predicates): - assert ( - predicates or how == "cross" - ), "expected non-empty predicates when not a cross join" + assert predicates or how == "cross", ( + "expected non-empty predicates when not a cross join" + ) if how == "asof": # the asof join match condition is always the first predicate by diff --git a/ibis/backends/sql/datatypes.py b/ibis/backends/sql/datatypes.py index 74fab33da25b..4e11b9f25954 100644 --- a/ibis/backends/sql/datatypes.py +++ b/ibis/backends/sql/datatypes.py @@ -629,9 +629,9 @@ def _from_sqlglot_TIMESTAMP_NS(cls, nullable: bool | None = None) -> dt.Timestam @classmethod def _from_ibis_GeoSpatial(cls, dtype: dt.GeoSpatial): - assert ( - dtype.geotype == "geometry" - ), "DuckDB only supports geometry types; geography types are not supported" + assert dtype.geotype == "geometry", ( + "DuckDB only supports geometry types; geography types are not supported" + ) return sge.DataType(this=typecode.GEOMETRY) _from_ibis_Point = _from_ibis_LineString = _from_ibis_Polygon = ( diff --git a/ibis/backends/tests/test_vectorized_udf.py b/ibis/backends/tests/test_vectorized_udf.py index cbcfce905c1e..1e78418ddddf 100644 --- a/ibis/backends/tests/test_vectorized_udf.py +++ b/ibis/backends/tests/test_vectorized_udf.py @@ -277,9 +277,9 @@ def test_elementwise_udf(udf_backend, udf_alltypes, udf_df, udf): result = expr.execute() expected_func = getattr(expr.op(), "__func__", getattr(udf, "func", None)) - assert ( - expected_func is not None - ), f"neither __func__ nor func attributes found on {udf} or expr object" + assert expected_func is not None, ( + f"neither __func__ nor func attributes found on {udf} or expr object" + ) expected = expected_func(udf_df["double_col"]) udf_backend.assert_series_equal(result, expected, check_names=False) @@ -292,9 +292,9 @@ def test_elementwise_udf_mutate(udf_backend, udf_alltypes, udf_df, udf): result = expr.execute() expected_func = getattr(udf_expr.op(), "__func__", getattr(udf, "func", None)) - assert ( - expected_func is not None - ), f"neither __func__ nor func attributes found on {udf} or expr object" + assert expected_func is not None, ( + f"neither __func__ nor func attributes found on {udf} or expr object" + ) expected = udf_df.assign(incremented=expected_func(udf_df["double_col"])) udf_backend.assert_series_equal(result["incremented"], expected["incremented"]) diff --git a/ibis/backends/tests/tpc/conftest.py b/ibis/backends/tests/tpc/conftest.py index eb7d86c8e620..b31f2e2e84cf 100644 --- a/ibis/backends/tests/tpc/conftest.py +++ b/ibis/backends/tests/tpc/conftest.py @@ -31,9 +31,9 @@ def pytest_pyfunc_call(pyfuncitem): testargs["backend"] = backend result = testfunction(**testargs) - assert ( - result is None - ), "test function should not return anything, did you mean to use assert?" + assert result is None, ( + "test function should not return anything, did you mean to use assert?" + ) return True diff --git a/ibis/expr/datatypes/core.py b/ibis/expr/datatypes/core.py index e66464663c73..ab21f8036bce 100644 --- a/ibis/expr/datatypes/core.py +++ b/ibis/expr/datatypes/core.py @@ -785,8 +785,7 @@ def __init__( if precision is not None: if not isinstance(precision, numbers.Integral): raise TypeError( - "Decimal type precision must be an integer; " - f"got {type(precision)}" + f"Decimal type precision must be an integer; got {type(precision)}" ) if precision < 0: raise ValueError("Decimal type precision cannot be negative") diff --git a/ibis/expr/datatypes/tests/test_value.py b/ibis/expr/datatypes/tests/test_value.py index 72d857bff7c2..5206ce30c3f3 100644 --- a/ibis/expr/datatypes/tests/test_value.py +++ b/ibis/expr/datatypes/tests/test_value.py @@ -45,7 +45,7 @@ class Foo(enum.Enum): (-32769, dt.int32), (-2147483649, dt.int64), (1.5, dt.double), - (decimal.Decimal(1.5), dt.decimal), + (decimal.Decimal("1.5"), dt.decimal), # parametric types (list("abc"), dt.Array(dt.string)), (set("abc"), dt.Array(dt.string)), diff --git a/ibis/expr/types/generic.py b/ibis/expr/types/generic.py index e741948a0b7e..6805228d81d2 100644 --- a/ibis/expr/types/generic.py +++ b/ibis/expr/types/generic.py @@ -1526,9 +1526,9 @@ def __pandas_result__( if data_mapper is None: from ibis.formats.pandas import PandasData as data_mapper - assert ( - len(df.columns) == 1 - ), "more than one column when converting columnar result DataFrame to Series" + assert len(df.columns) == 1, ( + "more than one column when converting columnar result DataFrame to Series" + ) # in theory we could use df.iloc[:, 0], but there seems to be a bug in # older geopandas where df.iloc[:, 0] doesn't return the same kind of # object as df.loc[:, column_name] when df is a GeoDataFrame diff --git a/ibis/expr/types/relations.py b/ibis/expr/types/relations.py index c95c6f4d4723..045273fdee83 100644 --- a/ibis/expr/types/relations.py +++ b/ibis/expr/types/relations.py @@ -2958,7 +2958,7 @@ def describe( col_max = lit(None).cast(float) col_mode = lit(None).cast(str) quantile_values = { - f"p{100*q:.6f}".rstrip("0").rstrip("."): lit(None).cast(float) + f"p{100 * q:.6f}".rstrip("0").rstrip("."): lit(None).cast(float) for q in quantile } @@ -2969,7 +2969,9 @@ def describe( col_min = col.min().cast(float) col_max = col.max().cast(float) quantile_values = { - f"p{100*q:.6f}".rstrip("0").rstrip("."): col.quantile(q).cast(float) + f"p{100 * q:.6f}".rstrip("0").rstrip("."): col.quantile(q).cast( + float + ) for q in quantile } elif typ.is_string(): diff --git a/ibis/expr/types/strings.py b/ibis/expr/types/strings.py index 1d54913d1be6..54e5f3d4aec4 100644 --- a/ibis/expr/types/strings.py +++ b/ibis/expr/types/strings.py @@ -98,12 +98,11 @@ def __getitem__(self, key: slice | int | ir.IntegerScalar) -> StringValue: raise ValueError("Step can only be 1") if start is not None and not isinstance(start, ir.Expr) and start < 0: raise ValueError( - "Negative slicing not yet supported, got start value " - f"of {start:d}" + f"Negative slicing not yet supported, got start value of {start:d}" ) if stop is not None and not isinstance(stop, ir.Expr) and stop < 0: raise ValueError( - "Negative slicing not yet supported, got stop value " f"of {stop:d}" + f"Negative slicing not yet supported, got stop value of {stop:d}" ) if start is None and stop is None: return self diff --git a/ibis/tests/expr/test_pretty_repr.py b/ibis/tests/expr/test_pretty_repr.py index c39ccc6ca184..f2e22f593f11 100644 --- a/ibis/tests/expr/test_pretty_repr.py +++ b/ibis/tests/expr/test_pretty_repr.py @@ -10,7 +10,7 @@ pytest.importorskip("rich") -from ibis.expr.types.pretty import format_column, format_values # noqa: E402 +from ibis.expr.types.pretty import format_column, format_values pd = pytest.importorskip("pandas")