Update pre-commit hooks - #22905
Conversation
….15.17 rapidsai/pre-commit-hooks: - Update copyright header format to '& AFFILIATES. All rights reserved.' ruff: - Rename TCH → TC rule prefix (ruff renamed flake8-type-checking) - Add PLC0415 to ignore (deferred/conditional imports are intentional) - Remove deprecated UP038 ignore - Exclude *.pyi from root ruff config (stubs use PEP 695/py312 syntax) - Fix RUF059: prefix unused unpacked variables with underscore - Fix RUF043: use raw strings for regex patterns in pytest match= - Fix RUF005: use tuple/list unpacking instead of concatenation - Fix RUF046: remove unnecessary int() cast - Fix PLW1508: use str defaults for os.environ.get() - Fix UP042: use enum.StrEnum instead of str+Enum - Suppress TC001/TC002 (imports used at runtime, not type-only) - Suppress PLW1641 (frozen dataclass generates __hash__ with custom __eq__) - Apply ruff-format changes
- Remove 16 unused type: ignore comments that mypy v2 no longer needs. - Add targeted type: ignore suppressions for 26 pre-existing type errors newly caught by mypy v2. - Fix UseDataPageMask enum stub to use member = value syntax per PEP 435 semantics change in mypy v2. - Move type: ignore[attr-defined] to import statement for importlib._bootstrap._ImportLockContext.
- Remove invalid inline '# ruff: noqa' directives in q66.py (ruff v0.15.17 now detects f-string variable usage, so F841 suppression is no longer needed). - Fix RUF043 (cast type arg as string literal) in test_stats.py. - Canonicalize copyright headers in q66.py and test_stats.py.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughUpdates lint configuration and pre-commit hooks, then applies typing-only and header changes across cudf and cudf_polars source code, tests, stubs, and eval scripts. A few internal expressions and test assertions also change without altering exported APIs. ChangesTC lint and typing cleanup
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
✨ Finishing Touches🧪 Generate unit tests (beta)
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@python/cudf/cudf/core/column/column.py`:
- Around line 3482-3485: The condition checking `dtype.kind` does not guard
against `dtype` being `None`, which will cause an AttributeError when `dtype` is
None for object-boolean inputs. Add a guard to check that `dtype` is not `None`
before dereferencing the `.kind` attribute in the if condition that currently
checks `dtype.kind != "b"`.
In `@python/cudf/cudf/tests/groupby/test_apply.py`:
- Around line 433-437: The regex pattern in the pytest.raises match argument
uses double-backslash escapes with a raw string, which doesn't correctly match
the actual error message containing parentheses. In the match pattern for
pytest.raises, change the double-escaped parentheses (\\( and \\)) to
single-escaped parentheses (\( and \)) since the raw string prefix means each
backslash is literal and a single backslash is needed to escape special regex
characters. This will allow the pattern to properly match the actual error
message "JIT GroupBy.apply() does not support DataFrame.sum()".
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: d09588de-e874-4e72-8e71-a33e3a84cddf
📒 Files selected for processing (103)
.pre-commit-config.yamldocs/cudf/source/_ext/PandasCompat.pypyproject.tomlpython/cudf/cudf/api/types.pypython/cudf/cudf/core/_internals/copying.pypython/cudf/cudf/core/accessors/string.pypython/cudf/cudf/core/column/categorical.pypython/cudf/cudf/core/column/column.pypython/cudf/cudf/core/column/datetime.pypython/cudf/cudf/core/column/decimal.pypython/cudf/cudf/core/column/interval.pypython/cudf/cudf/core/column/lists.pypython/cudf/cudf/core/column/numerical.pypython/cudf/cudf/core/column/numerical_base.pypython/cudf/cudf/core/column/string.pypython/cudf/cudf/core/column/temporal_base.pypython/cudf/cudf/core/column/timedelta.pypython/cudf/cudf/core/column_accessor.pypython/cudf/cudf/core/copy_types.pypython/cudf/cudf/core/groupby/groupby.pypython/cudf/cudf/core/index.pypython/cudf/cudf/core/indexed_frame.pypython/cudf/cudf/core/indexing_utils.pypython/cudf/cudf/core/multiindex.pypython/cudf/cudf/core/reshape.pypython/cudf/cudf/core/series.pypython/cudf/cudf/core/udf/groupby_utils.pypython/cudf/cudf/core/udf/masked_lowering.pypython/cudf/cudf/core/udf/utils.pypython/cudf/cudf/io/csv.pypython/cudf/cudf/pandas/module_accelerator.pypython/cudf/cudf/testing/dataset_generator.pypython/cudf/cudf/testing/testing.pypython/cudf/cudf/tests/dask/test_serialize.pypython/cudf/cudf/tests/dataframe/methods/test_diff.pypython/cudf/cudf/tests/dataframe/methods/test_query.pypython/cudf/cudf/tests/dataframe/methods/test_reductions.pypython/cudf/cudf/tests/dataframe/methods/test_sample.pypython/cudf/cudf/tests/dataframe/test_attributes.pypython/cudf/cudf/tests/general_functions/test_to_numeric.pypython/cudf/cudf/tests/general_functions/test_unique.pypython/cudf/cudf/tests/groupby/test_apply.pypython/cudf/cudf/tests/indexes/multiindex/test_repr.pypython/cudf/cudf/tests/input_output/test_avro.pypython/cudf/cudf/tests/input_output/test_json.pypython/cudf/cudf/tests/input_output/test_orc.pypython/cudf/cudf/tests/input_output/test_parquet.pypython/cudf/cudf/tests/private_objects/test_extension_compilation.pypython/cudf/cudf/tests/reshape/test_concat.pypython/cudf/cudf/tests/reshape/test_merge.pypython/cudf/cudf/tests/series/accessors/test_list.pypython/cudf/cudf/tests/series/accessors/test_str.pypython/cudf/cudf/tests/series/methods/test_astype.pypython/cudf/cudf/tests/series/methods/test_digitize.pypython/cudf/cudf/tests/series/methods/test_map.pypython/cudf/cudf/tests/series/methods/test_to_pandas.pypython/cudf/cudf/tests/test_flags.pypython/cudf/cudf/tests/text/test_text_methods.pypython/cudf/cudf_pandas_tests/test_cudf_pandas.pypython/cudf/cudf_pandas_tests/test_fast_slow_proxy.pypython/cudf/cudf_pandas_tests/third_party_integration_tests/tests/test_cuml.pypython/cudf/cudf_pandas_tests/third_party_integration_tests/tests/test_matplotlib.pypython/cudf_polars/cudf_polars/callback.pypython/cudf_polars/cudf_polars/containers/dataframe.pypython/cudf_polars/cudf_polars/containers/datatype.pypython/cudf_polars/cudf_polars/dsl/expressions/boolean.pypython/cudf_polars/cudf_polars/dsl/expressions/string.pypython/cudf_polars/cudf_polars/dsl/expressions/struct.pypython/cudf_polars/cudf_polars/dsl/expressions/unary.pypython/cudf_polars/cudf_polars/dsl/ir.pypython/cudf_polars/cudf_polars/dsl/to_ast.pypython/cudf_polars/cudf_polars/dsl/tracing.pypython/cudf_polars/cudf_polars/engine/core.pypython/cudf_polars/cudf_polars/engine/dask.pypython/cudf_polars/cudf_polars/engine/ray.pypython/cudf_polars/cudf_polars/engine/spmd.pypython/cudf_polars/cudf_polars/streaming/actor_graph/io.pypython/cudf_polars/cudf_polars/streaming/actor_graph/nodes.pypython/cudf_polars/cudf_polars/streaming/actor_graph/utils.pypython/cudf_polars/cudf_polars/streaming/benchmarks/pdsds_queries/q50.pypython/cudf_polars/cudf_polars/streaming/explain.pypython/cudf_polars/cudf_polars/streaming/shuffle.pypython/cudf_polars/cudf_polars/testing/asserts.pypython/cudf_polars/cudf_polars/testing/inject_gpu_engine.pypython/cudf_polars/pyproject.tomlpython/cudf_polars/tests/containers/test_datatype.pypython/cudf_polars/tests/expressions/test_rolling.pypython/cudf_polars/tests/streaming/test_parallel.pypython/cudf_polars/tests/streaming/test_sort.pypython/cudf_polars/tests/test_config.pypython/cudf_polars/tests/test_window_functions.pypython/cudf_polars/tests/testing/test_asserts.pypython/cudf_streaming/cudf_streaming/tests/test_channel_metadata.pypython/dask_cudf/dask_cudf/tests/test_accessor.pypython/dask_cudf/dask_cudf/tests/test_core.pypython/pylibcudf/pylibcudf/io/experimental/hybrid_scan.pyipython/pylibcudf/pyproject.tomlpython/pylibcudf/tests/io/test_csv.pypython/pylibcudf/tests/test_column_from_array.pypython/pylibcudf/tests/test_column_span.pypython/pylibcudf/tests/test_string_split_partition.pyskills/accelerated-computing-cudf/evals/files/cudf-null-handling/code/null_pipeline.pyskills/accelerated-computing-cudf/evals/files/cudf-pivot-melt/code/reshape_analysis.py
The ruff UP025 autofix converted the match string to a raw string but
the double-backslash escapes were not adjusted. In a raw string,
'\\(' is literal backslash-backslash-paren (matching a backslash
before a paren), not an escaped parenthesis. Use single backslash
to correctly match literal parentheses in the error message.
|
Addressed CodeRabbit's review comments: test_apply.py regex (fixed in a64c619): Good catch — the ruff column.py dtype None guard (not fixing): The |
Per reviewer feedback, call functions without capturing unused return values instead of using _prefixed variable names.
|
/merge |
Updates all pre-commit hooks to their latest versions except
clang-formatsince we typically keep that version synchronized across RAPIDS for devcontainers.Replaces #22025
Hook updates
Notable changes
ruff v0.15.17
TCHrule prefix toTCin all pyproject.toml configs.RUF059,RUF043,RUF005,RUF046,PLW1508.Scopetoenum.StrEnum(UP042).PLW1641(frozen dataclass generates__hash__with custom__eq__).TC001/TC002where runtime imports are needed.PLC0415to global ignore (intentional deferred/conditional imports).*.pyifrom root ruff config (stubs use PEP 695 syntax, root targets Python 3.11).UP038ignore frompython/cudf_polars/pyproject.toml.mypy v2.1.0
# type: ignorecomments that mypy v2 no longer needs.# type: ignore[code]suppressions for 26 pre-existing type errors newly caught by mypy v2.UseDataPageMaskenum stub to usemember = valuesyntax per PEP 435 semantics change.clang-format (not updated)
Updating clang-format from v20.1.8 to v22.1.5 causes a conflict between
ReflowCommentsand the verify-copyright hook (the long SPDX header line exceeds ColumnLimit and gets wrapped, which the copyright hook then unwraps, creating an infinite oscillation). This will be addressed in a separate PR.