From ba3e9e270a084d531b10a6f4f20eab6fdd440263 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Mon, 5 Feb 2024 06:34:08 -0500 Subject: [PATCH] chore(dev-deps): bump ruff to v0.2.0 (#8219) --- .../clickhouse/tests/test_operators.py | 2 +- ibis/backends/pandas/execution/temporal.py | 8 ++-- ibis/backends/postgres/datatypes.py | 2 +- ibis/backends/risingwave/datatypes.py | 2 +- ibis/backends/tests/test_map.py | 2 +- ibis/common/patterns.py | 2 +- ibis/common/tests/test_patterns.py | 26 ++++++------- ibis/common/typing.py | 2 +- poetry.lock | 38 ++++++++++--------- pyproject.toml | 16 ++++---- requirements-dev.txt | 2 +- 11 files changed, 52 insertions(+), 50 deletions(-) diff --git a/ibis/backends/clickhouse/tests/test_operators.py b/ibis/backends/clickhouse/tests/test_operators.py index f4e27fbdc361..4db313f76a93 100644 --- a/ibis/backends/clickhouse/tests/test_operators.py +++ b/ibis/backends/clickhouse/tests/test_operators.py @@ -260,7 +260,7 @@ def test_array_index(con, arr, gen_idx): ) def test_array_concat(con, arrays): expr = L([]).cast("!array") - expected = sum(arrays, []) + expected = sum(arrays, []) # noqa: RUF017 for arr in arrays: expr += L(arr, type="!array") diff --git a/ibis/backends/pandas/execution/temporal.py b/ibis/backends/pandas/execution/temporal.py index a2f2b5d8b5ec..c294c373211d 100644 --- a/ibis/backends/pandas/execution/temporal.py +++ b/ibis/backends/pandas/execution/temporal.py @@ -130,7 +130,7 @@ def execute_timestamp_truncate(op, data, **kwargs): def execute_interval_from_integer_series(op, data, **kwargs): unit = op.unit.short resolution = op.unit.plural - cls = OFFSET_CLASS.get(unit, None) + cls = OFFSET_CLASS.get(unit) # fast path for timedelta conversion if cls is None: @@ -142,7 +142,7 @@ def execute_interval_from_integer_series(op, data, **kwargs): def execute_interval_from_integer_integer_types(op, data, **kwargs): unit = op.unit.short resolution = op.unit.plural - cls = OFFSET_CLASS.get(unit, None) + cls = OFFSET_CLASS.get(unit) if cls is None: return pd.Timedelta(data, unit=unit) @@ -154,7 +154,7 @@ def execute_cast_integer_to_interval_series(op, data, type, **kwargs): to = op.to unit = to.unit.short resolution = to.unit.plural - cls = OFFSET_CLASS.get(unit, None) + cls = OFFSET_CLASS.get(unit) if cls is None: return data.astype(f"timedelta64[{unit}]") @@ -166,7 +166,7 @@ def execute_cast_integer_to_interval_integer_types(op, data, type, **kwargs): to = op.to unit = to.unit.short resolution = to.unit.plural - cls = OFFSET_CLASS.get(unit, None) + cls = OFFSET_CLASS.get(unit) if cls is None: return pd.Timedelta(data, unit=unit) diff --git a/ibis/backends/postgres/datatypes.py b/ibis/backends/postgres/datatypes.py index 4a2bd2c1f71f..095df636a0f6 100644 --- a/ibis/backends/postgres/datatypes.py +++ b/ibis/backends/postgres/datatypes.py @@ -73,7 +73,7 @@ def to_ibis(cls, typ: sat.TypeEngine, nullable: bool = True) -> dt.DataType: return dt.Map(dt.string, dt.string, nullable=nullable) elif isinstance(typ, psql.INTERVAL): field = typ.fields.upper() - if (unit := _postgres_interval_fields.get(field, None)) is None: + if (unit := _postgres_interval_fields.get(field)) is None: raise ValueError(f"Unknown PostgreSQL interval field {field!r}") elif unit in {"Y", "M"}: raise ValueError( diff --git a/ibis/backends/risingwave/datatypes.py b/ibis/backends/risingwave/datatypes.py index 389210486a6f..8ff106306f0b 100644 --- a/ibis/backends/risingwave/datatypes.py +++ b/ibis/backends/risingwave/datatypes.py @@ -68,7 +68,7 @@ def to_ibis(cls, typ: sat.TypeEngine, nullable: bool = True) -> dt.DataType: return dt.Map(dt.string, dt.string, nullable=nullable) elif isinstance(typ, psql.INTERVAL): field = typ.fields.upper() - if (unit := _postgres_interval_fields.get(field, None)) is None: + if (unit := _postgres_interval_fields.get(field)) is None: raise ValueError(f"Unknown Risingwave interval field {field!r}") elif unit in {"Y", "M"}: raise ValueError( diff --git a/ibis/backends/tests/test_map.py b/ibis/backends/tests/test_map.py index 10cc901419d5..67eccf7918f8 100644 --- a/ibis/backends/tests/test_map.py +++ b/ibis/backends/tests/test_map.py @@ -225,7 +225,7 @@ def test_literal_map_getitem_broadcast(backend, alltypes, df): expr = lookup_table[alltypes.string_col] result = expr.name("tmp").execute() - expected = df.string_col.apply(lambda x: value.get(x, None)).rename("tmp") + expected = df.string_col.apply(value.get).rename("tmp") backend.assert_series_equal(result, expected) diff --git a/ibis/common/patterns.py b/ibis/common/patterns.py index 2e48c697d5f1..224e997a4575 100644 --- a/ibis/common/patterns.py +++ b/ibis/common/patterns.py @@ -1410,7 +1410,7 @@ def match(self, values, context): if result is NoMatch: return NoMatch else: - return sum(result, []) + return [el for lst in result for el in lst] def _maybe_unwrap_capture(obj): diff --git a/ibis/common/tests/test_patterns.py b/ibis/common/tests/test_patterns.py index aa770da9e79c..29bfe0430efe 100644 --- a/ibis/common/tests/test_patterns.py +++ b/ibis/common/tests/test_patterns.py @@ -263,10 +263,10 @@ def test_generic_instance_of_with_covariant_typevar(): assert p.match(My(1, 2, "3"), context={}) == My(1, 2, "3") assert p.describe() == "a My[int, Any]" - assert match(My[int, AnyType], v := My(1, 2, "3")) == v - assert match(My[int, int], v := My(1, 2, "3")) == v + assert match(My[int, AnyType], v := My(1, 2, "3")) == v # noqa: RUF018 + assert match(My[int, int], v := My(1, 2, "3")) == v # noqa: RUF018 assert match(My[int, float], My(1, 2, "3")) is NoMatch - assert match(My[int, float], v := My(1, 2.0, "3")) == v + assert match(My[int, float], v := My(1, 2.0, "3")) == v # noqa: RUF018 def test_generic_instance_of_disallow_nested_coercion(): @@ -777,12 +777,12 @@ def test_matching(): assert Capture("pi", InstanceOf(float)) == "pi" @ InstanceOf(float) assert Capture("pi", InstanceOf(float)) == "pi" @ InstanceOf(float) - assert match(Capture("pi", InstanceOf(float)), 3.14, ctx := {}) == 3.14 + assert match(Capture("pi", InstanceOf(float)), 3.14, ctx := {}) == 3.14 # noqa: RUF018 assert ctx == {"pi": 3.14} - assert match("pi" @ InstanceOf(float), 3.14, ctx := {}) == 3.14 + assert match("pi" @ InstanceOf(float), 3.14, ctx := {}) == 3.14 # noqa: RUF018 assert ctx == {"pi": 3.14} - assert match("pi" @ InstanceOf(float), 3.14, ctx := {}) == 3.14 + assert match("pi" @ InstanceOf(float), 3.14, ctx := {}) == 3.14 # noqa: RUF018 assert ctx == {"pi": 3.14} assert match(InstanceOf(int) | InstanceOf(float), 3) == 3 @@ -894,13 +894,13 @@ def test_matching_sequence_pattern_keeps_original_type(): def test_matching_sequence_with_captures(): v = list(range(1, 9)) assert match([1, 2, 3, 4, Some(...)], v) == v - assert match([1, 2, 3, 4, "rest" @ Some(...)], v, ctx := {}) == v + assert match([1, 2, 3, 4, "rest" @ Some(...)], v, ctx := {}) == v # noqa: RUF018 assert ctx == {"rest": [5, 6, 7, 8]} v = list(range(5)) - assert match([0, 1, x @ Some(...), 4], v, ctx := {}) == v + assert match([0, 1, x @ Some(...), 4], v, ctx := {}) == v # noqa: RUF018 assert ctx == {"x": [2, 3]} - assert match([0, 1, "var" @ Some(...), 4], v, ctx := {}) == v + assert match([0, 1, "var" @ Some(...), 4], v, ctx := {}) == v # noqa: RUF018 assert ctx == {"var": [2, 3]} p = [ @@ -911,7 +911,7 @@ def test_matching_sequence_with_captures(): 6, ] v = [0, 1, 2, 3, 4.0, 5.0, 6] - assert match(p, v, ctx := {}) == v + assert match(p, v, ctx := {}) == v # noqa: RUF018 assert ctx == {"ints": [2, 3], "last_float": 5.0} @@ -927,7 +927,7 @@ def test_matching_sequence_remaining(): assert match([1, 2, 3, Some(InstanceOf(int) & Between(0, 10))], five) == five assert match([1, 2, 3, Some(InstanceOf(int) & Between(0, 4))], five) is NoMatch assert match([1, 2, 3, Some(int, at_least=2)], four) is NoMatch - assert match([1, 2, 3, "res" @ Some(int, at_least=2)], five, ctx := {}) == five + assert match([1, 2, 3, "res" @ Some(int, at_least=2)], five, ctx := {}) == five # noqa: RUF018 assert ctx == {"res": [4, 5]} @@ -944,12 +944,12 @@ def test_matching_sequence_complicated(): "a": [2, 3], "b": [5, 6, 7], } - assert match(pat, range(1, 10), ctx := {}) == list(range(1, 10)) + assert match(pat, range(1, 10), ctx := {}) == list(range(1, 10)) # noqa: RUF018 assert ctx == expected pat = [1, 2, Capture("remaining", Some(...))] expected = {"remaining": [3, 4, 5, 6, 7, 8, 9]} - assert match(pat, range(1, 10), ctx := {}) == list(range(1, 10)) + assert match(pat, range(1, 10), ctx := {}) == list(range(1, 10)) # noqa: RUF018 assert ctx == expected v = [0, [1, 2, "3"], [1, 2, "4"], 3] diff --git a/ibis/common/typing.py b/ibis/common/typing.py index 170ca2bd2b40..7bcc7d62d685 100644 --- a/ibis/common/typing.py +++ b/ibis/common/typing.py @@ -203,7 +203,7 @@ def evaluate_annotations( else: localns = dict(Self=f"{module_name}.{class_name}") return { - k: eval(v, globalns, localns) if isinstance(v, str) else v # noqa: PGH001 + k: eval(v, globalns, localns) if isinstance(v, str) else v for k, v in annots.items() } diff --git a/poetry.lock b/poetry.lock index 4ac53bf31def..27fbf96d84b7 100644 --- a/poetry.lock +++ b/poetry.lock @@ -4361,6 +4361,8 @@ files = [ {file = "psycopg2-2.9.9-cp310-cp310-win_amd64.whl", hash = "sha256:426f9f29bde126913a20a96ff8ce7d73fd8a216cfb323b1f04da402d452853c3"}, {file = "psycopg2-2.9.9-cp311-cp311-win32.whl", hash = "sha256:ade01303ccf7ae12c356a5e10911c9e1c51136003a9a1d92f7aa9d010fb98372"}, {file = "psycopg2-2.9.9-cp311-cp311-win_amd64.whl", hash = "sha256:121081ea2e76729acfb0673ff33755e8703d45e926e416cb59bae3a86c6a4981"}, + {file = "psycopg2-2.9.9-cp312-cp312-win32.whl", hash = "sha256:d735786acc7dd25815e89cc4ad529a43af779db2e25aa7c626de864127e5a024"}, + {file = "psycopg2-2.9.9-cp312-cp312-win_amd64.whl", hash = "sha256:a7653d00b732afb6fc597e29c50ad28087dcb4fbfb28e86092277a559ae4e693"}, {file = "psycopg2-2.9.9-cp37-cp37m-win32.whl", hash = "sha256:5e0d98cade4f0e0304d7d6f25bbfbc5bd186e07b38eac65379309c4ca3193efa"}, {file = "psycopg2-2.9.9-cp37-cp37m-win_amd64.whl", hash = "sha256:7e2dacf8b009a1c1e843b5213a87f7c544b2b042476ed7755be813eaf4e8347a"}, {file = "psycopg2-2.9.9-cp38-cp38-win32.whl", hash = "sha256:ff432630e510709564c01dafdbe996cb552e0b9f3f065eb89bdce5bd31fabf4c"}, @@ -5983,28 +5985,28 @@ pyasn1 = ">=0.1.3" [[package]] name = "ruff" -version = "0.1.13" +version = "0.2.0" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.1.13-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:e3fd36e0d48aeac672aa850045e784673449ce619afc12823ea7868fcc41d8ba"}, - {file = "ruff-0.1.13-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:9fb6b3b86450d4ec6a6732f9f60c4406061b6851c4b29f944f8c9d91c3611c7a"}, - {file = "ruff-0.1.13-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b13ba5d7156daaf3fd08b6b993360a96060500aca7e307d95ecbc5bb47a69296"}, - {file = "ruff-0.1.13-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:9ebb40442f7b531e136d334ef0851412410061e65d61ca8ce90d894a094feb22"}, - {file = "ruff-0.1.13-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:226b517f42d59a543d6383cfe03cccf0091e3e0ed1b856c6824be03d2a75d3b6"}, - {file = "ruff-0.1.13-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:5f0312ba1061e9b8c724e9a702d3c8621e3c6e6c2c9bd862550ab2951ac75c16"}, - {file = "ruff-0.1.13-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2f59bcf5217c661254bd6bc42d65a6fd1a8b80c48763cb5c2293295babd945dd"}, - {file = "ruff-0.1.13-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e6894b00495e00c27b6ba61af1fc666f17de6140345e5ef27dd6e08fb987259d"}, - {file = "ruff-0.1.13-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9a1600942485c6e66119da294c6294856b5c86fd6df591ce293e4a4cc8e72989"}, - {file = "ruff-0.1.13-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:ee3febce7863e231a467f90e681d3d89210b900d49ce88723ce052c8761be8c7"}, - {file = "ruff-0.1.13-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:dcaab50e278ff497ee4d1fe69b29ca0a9a47cd954bb17963628fa417933c6eb1"}, - {file = "ruff-0.1.13-py3-none-musllinux_1_2_i686.whl", hash = "sha256:f57de973de4edef3ad3044d6a50c02ad9fc2dff0d88587f25f1a48e3f72edf5e"}, - {file = "ruff-0.1.13-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:7a36fa90eb12208272a858475ec43ac811ac37e91ef868759770b71bdabe27b6"}, - {file = "ruff-0.1.13-py3-none-win32.whl", hash = "sha256:a623349a505ff768dad6bd57087e2461be8db58305ebd5577bd0e98631f9ae69"}, - {file = "ruff-0.1.13-py3-none-win_amd64.whl", hash = "sha256:f988746e3c3982bea7f824c8fa318ce7f538c4dfefec99cd09c8770bd33e6539"}, - {file = "ruff-0.1.13-py3-none-win_arm64.whl", hash = "sha256:6bbbc3042075871ec17f28864808540a26f0f79a4478c357d3e3d2284e832998"}, - {file = "ruff-0.1.13.tar.gz", hash = "sha256:e261f1baed6291f434ffb1d5c6bd8051d1c2a26958072d38dfbec39b3dda7352"}, + {file = "ruff-0.2.0-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:638ea3294f800d18bae84a492cb5a245c8d29c90d19a91d8e338937a4c27fca0"}, + {file = "ruff-0.2.0-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:3ff35433fcf4dff6d610738712152df6b7d92351a1bde8e00bd405b08b3d5759"}, + {file = "ruff-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bf9faafbdcf4f53917019f2c230766da437d4fd5caecd12ddb68bb6a17d74399"}, + {file = "ruff-0.2.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:8153a3e4128ed770871c47545f1ae7b055023e0c222ff72a759f5a341ee06483"}, + {file = "ruff-0.2.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e8a75a98ae989a27090e9c51f763990ad5bbc92d20626d54e9701c7fe597f399"}, + {file = "ruff-0.2.0-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:87057dd2fdde297130ff99553be8549ca38a2965871462a97394c22ed2dfc19d"}, + {file = "ruff-0.2.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6d232f99d3ab00094ebaf88e0fb7a8ccacaa54cc7fa3b8993d9627a11e6aed7a"}, + {file = "ruff-0.2.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3d3c641f95f435fc6754b05591774a17df41648f0daf3de0d75ad3d9f099ab92"}, + {file = "ruff-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3826fb34c144ef1e171b323ed6ae9146ab76d109960addca730756dc19dc7b22"}, + {file = "ruff-0.2.0-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:eceab7d85d09321b4de18b62d38710cf296cb49e98979960a59c6b9307c18cfe"}, + {file = "ruff-0.2.0-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:30ad74687e1f4a9ff8e513b20b82ccadb6bd796fe5697f1e417189c5cde6be3e"}, + {file = "ruff-0.2.0-py3-none-musllinux_1_2_i686.whl", hash = "sha256:a7e3818698f8460bd0f8d4322bbe99db8327e9bc2c93c789d3159f5b335f47da"}, + {file = "ruff-0.2.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:edf23041242c48b0d8295214783ef543847ef29e8226d9f69bf96592dba82a83"}, + {file = "ruff-0.2.0-py3-none-win32.whl", hash = "sha256:e155147199c2714ff52385b760fe242bb99ea64b240a9ffbd6a5918eb1268843"}, + {file = "ruff-0.2.0-py3-none-win_amd64.whl", hash = "sha256:ba918e01cdd21e81b07555564f40d307b0caafa9a7a65742e98ff244f5035c59"}, + {file = "ruff-0.2.0-py3-none-win_arm64.whl", hash = "sha256:3fbaff1ba9564a2c5943f8f38bc221f04bac687cc7485e45237579fee7ccda79"}, + {file = "ruff-0.2.0.tar.gz", hash = "sha256:63856b91837606c673537d2889989733d7dffde553828d3b0f0bacfa6def54be"}, ] [[package]] diff --git a/pyproject.toml b/pyproject.toml index 300360d3c27e..a1a7a2112651 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -401,6 +401,11 @@ builtin = "clear,rare,names" [tool.ruff] line-length = 88 +respect-gitignore = true +exclude = [".direnv", "result-*", "*_py310.py", "decompiled.py"] +target-version = "py39" + +[tool.ruff.lint] select = [ "B", # flake8-bugbear "BLE", # flake8-blind-except @@ -430,7 +435,6 @@ select = [ "W", # pycodestyle "YTT", # flake8-2020 ] -respect-gitignore = true ignore = [ "B028", # required stacklevel argument to warn "B904", # raise from e or raise from None in exception handlers @@ -477,8 +481,6 @@ ignore = [ "SIM300", # yoda conditions "UP007", # Optional[str] -> str | None ] -exclude = ["*_py310.py"] -target-version = "py39" # none of these codes will be automatically fixed by ruff unfixable = [ "T201", # print statements @@ -487,25 +489,23 @@ unfixable = [ "F841", # unused variables ] -[tool.ruff.pyupgrade] +[tool.ruff.lint.pyupgrade] keep-runtime-typing = true -[tool.ruff.isort] +[tool.ruff.lint.isort] required-imports = ["from __future__ import annotations"] -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "*test*.py" = [ "D", # ignore all docstring lints in tests ] "{docs,ci}/**/*.py" = ["INP001"] -"*/decompiled.py" = ["ALL"] "{ci/release/verify_release,docs/**/*_impl}.py" = [ "T201", ] # prints output using `print` "docs/**/{datafusion,polars}_*.py" = ["T201"] # prints output using `print` [tool.ruff.format] -exclude = [".direnv", "result-*", "_py310.py", "decompiled.py"] docstring-code-format = true docstring-code-line-length = 88 diff --git a/requirements-dev.txt b/requirements-dev.txt index ab9141b826d6..0cb17917c8d7 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -223,7 +223,7 @@ requests[socks]==2.31.0 ; python_version >= "3.10" and python_version < "3.13" rich==13.7.0 ; python_version >= "3.9" and python_version < "4.0" rpds-py==0.17.1 ; python_version >= "3.10" and python_version < "3.13" rsa==4.9 ; python_version >= "3.9" and python_version < "4" -ruff==0.1.13 ; python_version >= "3.9" and python_version < "4.0" +ruff==0.2.0 ; python_version >= "3.9" and python_version < "4.0" scikit-learn==1.3.2 ; python_version >= "3.10" and python_version < "3.13" scipy==1.11.4 ; python_version >= "3.10" and python_version < "3.13" scooby==0.9.2 ; python_version >= "3.10" and python_version < "3.13"