From 32e7a249ac021b73e555d7c2489e1c9e37fe1250 Mon Sep 17 00:00:00 2001 From: Stijn de Gooijer Date: Tue, 17 Oct 2023 13:48:32 +0200 Subject: [PATCH] chore(python): Bump lint dependencies (#11802) --- .github/workflows/lint-global.yml | 2 +- py-polars/polars/series/utils.py | 2 +- py-polars/polars/utils/_async.py | 4 ++-- py-polars/polars/utils/_construction.py | 2 +- py-polars/requirements-lint.txt | 6 +++--- py-polars/tests/test_udfs.py | 2 +- .../tests/unit/operations/test_aggregations.py | 1 - py-polars/tests/unit/series/test_series.py | 4 ++-- py-polars/tests/unit/sql/test_sql.py | 16 +++++++--------- py-polars/tests/unit/test_exprs.py | 4 ++-- 10 files changed, 20 insertions(+), 23 deletions(-) diff --git a/.github/workflows/lint-global.yml b/.github/workflows/lint-global.yml index 2ebcc0dca3b0..07344c893be9 100644 --- a/.github/workflows/lint-global.yml +++ b/.github/workflows/lint-global.yml @@ -15,4 +15,4 @@ jobs: - name: Lint Markdown and TOML uses: dprint/check@v2.2 - name: Spell Check with Typos - uses: crate-ci/typos@v1.16.8 + uses: crate-ci/typos@v1.16.20 diff --git a/py-polars/polars/series/utils.py b/py-polars/polars/series/utils.py index 00ab66ba5e5e..9e5c95477b74 100644 --- a/py-polars/polars/series/utils.py +++ b/py-polars/polars/series/utils.py @@ -89,7 +89,7 @@ def _undecorated(function: Callable[P, T]) -> Callable[P, T]: def call_expr(func: SeriesMethod) -> SeriesMethod: """Dispatch Series method to an expression implementation.""" - @wraps(func) # type: ignore[arg-type] + @wraps(func) def wrapper(self: Any, *args: P.args, **kwargs: P.kwargs) -> Series: s = wrap_s(self._s) expr = F.col(s.name) diff --git a/py-polars/polars/utils/_async.py b/py-polars/polars/utils/_async.py index 42ddfe85c313..3294bca9428f 100644 --- a/py-polars/polars/utils/_async.py +++ b/py-polars/polars/utils/_async.py @@ -24,8 +24,8 @@ def __init__(self) -> None: "polars.collect_all_async(gevent=True)" ) - from gevent.event import AsyncResult # type: ignore[import] - from gevent.hub import get_hub # type: ignore[import] + from gevent.event import AsyncResult # type: ignore[import-untyped] + from gevent.hub import get_hub # type: ignore[import-untyped] self._value: None | Exception | PyDataFrame | list[PyDataFrame] = None self._result = AsyncResult() diff --git a/py-polars/polars/utils/_construction.py b/py-polars/polars/utils/_construction.py index b98bfe41a764..9e38b3e4d38f 100644 --- a/py-polars/polars/utils/_construction.py +++ b/py-polars/polars/utils/_construction.py @@ -860,7 +860,7 @@ def dict_to_pydf( lambda t: pl.Series(t[0], t[1]) if isinstance(t[1], np.ndarray) else t[1], - [(k, v) for k, v in data.items()], + list(data.items()), ), ) ) diff --git a/py-polars/requirements-lint.txt b/py-polars/requirements-lint.txt index 0748b30ce8e8..20bdfbddf117 100644 --- a/py-polars/requirements-lint.txt +++ b/py-polars/requirements-lint.txt @@ -1,5 +1,5 @@ black==23.9.1 blackdoc==0.3.8 -mypy==1.5.1 -ruff==0.0.287 -typos==1.16.8 +mypy==1.6.0 +ruff==0.1.0 +typos==1.16.20 diff --git a/py-polars/tests/test_udfs.py b/py-polars/tests/test_udfs.py index 956edaecd1f6..c3f9c32360fa 100644 --- a/py-polars/tests/test_udfs.py +++ b/py-polars/tests/test_udfs.py @@ -159,7 +159,7 @@ ) def test_bytecode_parser_expression(col: str, func: str, expected: str) -> None: try: - import udfs # type: ignore[import] + import udfs # type: ignore[import-not-found] except ModuleNotFoundError as exc: assert "No module named 'udfs'" in str(exc) # noqa: PT017 # Skip test if udfs can't be imported because it's not in the path. diff --git a/py-polars/tests/unit/operations/test_aggregations.py b/py-polars/tests/unit/operations/test_aggregations.py index 5dff526eabc7..0cd22d787120 100644 --- a/py-polars/tests/unit/operations/test_aggregations.py +++ b/py-polars/tests/unit/operations/test_aggregations.py @@ -132,7 +132,6 @@ def test_quantile_vs_numpy(tp: type, n: int) -> None: np_result = np.quantile(a, q) except IndexError: np_result = None - pass if np_result: # nan check if np_result != np_result: diff --git a/py-polars/tests/unit/series/test_series.py b/py-polars/tests/unit/series/test_series.py index 559783025df9..3fab208b1131 100644 --- a/py-polars/tests/unit/series/test_series.py +++ b/py-polars/tests/unit/series/test_series.py @@ -1438,10 +1438,10 @@ def test_bitwise() -> None: # ensure mistaken use of logical 'and'/'or' raises an exception with pytest.raises(TypeError, match="ambiguous"): - a and b + a and b # type: ignore[redundant-expr] with pytest.raises(TypeError, match="ambiguous"): - a or b + a or b # type: ignore[redundant-expr] def test_to_numpy(monkeypatch: Any) -> None: diff --git a/py-polars/tests/unit/sql/test_sql.py b/py-polars/tests/unit/sql/test_sql.py index 73faef160377..ca281c380ab0 100644 --- a/py-polars/tests/unit/sql/test_sql.py +++ b/py-polars/tests/unit/sql/test_sql.py @@ -942,12 +942,14 @@ def test_sql_trim(foods_ipc_path: Path) -> None: "BY NAME", [(1, "zz"), (2, "yy"), (3, "xx")], ), - ( - # note: waiting for "https://github.com/sqlparser-rs/sqlparser-rs/pull/997" + pytest.param( ["c1", "c2"], ["c2", "c1"], "DISTINCT BY NAME", - None, # [(1, "zz"), (2, "yy"), (3, "xx")], + [(1, "zz"), (2, "yy"), (3, "xx")], + # TODO: Remove xfail marker when supported added in sqlparser-rs + # https://github.com/sqlparser-rs/sqlparser-rs/pull/997 + marks=pytest.mark.xfail, ), ], ) @@ -955,7 +957,7 @@ def test_sql_union( cols1: list[str], cols2: list[str], union_subtype: str, - expected: dict[str, list[int] | list[str]] | None, + expected: list[tuple[int, str]], ) -> None: with pl.SQLContext( frame1=pl.DataFrame({"c1": [1, 2], "c2": ["zz", "yy"]}), @@ -967,11 +969,7 @@ def test_sql_union( UNION {union_subtype} SELECT {', '.join(cols2)} FROM frame2 """ - if expected is not None: - assert sorted(ctx.execute(query).rows()) == expected - else: - with pytest.raises(pl.ComputeError, match="sql parser error"): - ctx.execute(query) + assert sorted(ctx.execute(query).rows()) == expected def test_sql_nullif_coalesce(foods_ipc_path: Path) -> None: diff --git a/py-polars/tests/unit/test_exprs.py b/py-polars/tests/unit/test_exprs.py index 8518755eb4f1..a75fa521663a 100644 --- a/py-polars/tests/unit/test_exprs.py +++ b/py-polars/tests/unit/test_exprs.py @@ -428,10 +428,10 @@ def test_logical_boolean() -> None: # note, cannot use expressions in logical # boolean context (eg: and/or/not operators) with pytest.raises(TypeError, match="ambiguous"): - pl.col("colx") and pl.col("coly") + pl.col("colx") and pl.col("coly") # type: ignore[redundant-expr] with pytest.raises(TypeError, match="ambiguous"): - pl.col("colx") or pl.col("coly") + pl.col("colx") or pl.col("coly") # type: ignore[redundant-expr] df = pl.DataFrame({"a": [1, 2, 3, 4, 5], "b": [1, 2, 3, 4, 5]})