Skip to content

Update pre-commit hooks - #22905

Merged
rapids-bot[bot] merged 10 commits into
NVIDIA:mainfrom
vyasr:feat/pre-commit-update
Jun 16, 2026
Merged

Update pre-commit hooks#22905
rapids-bot[bot] merged 10 commits into
NVIDIA:mainfrom
vyasr:feat/pre-commit-update

Conversation

@vyasr

@vyasr vyasr commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Updates all pre-commit hooks to their latest versions except clang-format since we typically keep that version synchronized across RAPIDS for devcontainers.

Replaces #22025

Hook updates

Hook Old New
codespell v2.4.1 v2.4.2
dependency-file-generator v1.20.2 v1.20.3
zizmor v1.24.1 v1.25.2
cython-lint v0.18.1 v0.19.0
rapidsai/pre-commit-hooks v1.4.1 v1.5.1
ruff v0.9.3 v0.15.17
mypy v1.13.0 v2.1.0

Notable changes

ruff v0.15.17

  • Renamed TCH rule prefix to TC in all pyproject.toml configs.
  • Fixed new lint errors: RUF059, RUF043, RUF005, RUF046, PLW1508.
  • Converted Scope to enum.StrEnum (UP042).
  • Suppressed PLW1641 (frozen dataclass generates __hash__ with custom __eq__).
  • Suppressed TC001/TC002 where runtime imports are needed.
  • Added PLC0415 to global ignore (intentional deferred/conditional imports).
  • Excluded *.pyi from root ruff config (stubs use PEP 695 syntax, root targets Python 3.11).
  • Removed deprecated UP038 ignore from python/cudf_polars/pyproject.toml.

mypy v2.1.0

  • Removed 16 unused # type: ignore comments that mypy v2 no longer needs.
  • Added targeted # type: ignore[code] suppressions for 26 pre-existing type errors newly caught by mypy v2.
  • Fixed UseDataPageMask enum stub to use member = value syntax per PEP 435 semantics change.

clang-format (not updated)

Updating clang-format from v20.1.8 to v22.1.5 causes a conflict between ReflowComments and 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.

vyasr added 6 commits June 16, 2026 08:57
….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.
@vyasr
vyasr requested review from a team as code owners June 16, 2026 18:10
@vyasr
vyasr requested review from bdice and galipremsagar June 16, 2026 18:10
@github-actions github-actions Bot added Python Affects Python cuDF API. cudf.pandas Issues specific to cudf.pandas cudf-polars Issues specific to cudf-polars pylibcudf Issues specific to the pylibcudf package labels Jun 16, 2026
@GPUtester GPUtester moved this to In Progress in cuDF Python Jun 16, 2026
vyasr added 2 commits June 16, 2026 11:16
- 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.
@vyasr vyasr added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Jun 16, 2026
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a804af42-2d68-4e0c-8f47-814d4fac5fa7

📥 Commits

Reviewing files that changed from the base of the PR and between a64c619 and c6a6ac9.

📒 Files selected for processing (2)
  • skills/accelerated-computing-cudf/evals/files/cudf-null-handling/code/null_pipeline.py
  • skills/accelerated-computing-cudf/evals/files/cudf-pivot-melt/code/reshape_analysis.py
✅ Files skipped from review due to trivial changes (1)
  • skills/accelerated-computing-cudf/evals/files/cudf-null-handling/code/null_pipeline.py

📝 Walkthrough

Summary by CodeRabbit

  • Chores
    • Updated SPDX copyright headers across the project.
    • Refreshed tooling/lint configuration and improved typing/cast consistency (type-checking-only changes).
  • Bug Fixes
    • Improved default heap sizing for string UDFs by reliably converting the environment value to an integer.
    • Adjusted sample(frac=...) row-count calculation to use consistent rounding.
    • Updated Polars Scope to use string-backed enum values for more consistent serialization.
  • Tests
    • Standardized many pytest.raises(..., match=...) assertions to use raw-string regex patterns.

Walkthrough

Updates 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.

Changes

TC lint and typing cleanup

Layer / File(s) Summary
Lint and hook config
.pre-commit-config.yaml, pyproject.toml, python/cudf_polars/pyproject.toml, python/pylibcudf/pyproject.toml
Ruff selection switches to TC, excludes gain *.pyi, and multiple pre-commit hook revisions are bumped.
cudf source typing updates
docs/cudf/source/_ext/PandasCompat.py, python/cudf/cudf/api/types.py, python/cudf/cudf/core/..., python/cudf/cudf/io/csv.py, python/cudf/cudf/pandas/module_accelerator.py, python/cudf/cudf/testing/*
cudf source files update SPDX headers, convert many typing.cast targets to string-literal forms, adjust type-ignore usage, and include a few internal behavior-preserving expression changes.
cudf_polars source updates
python/cudf_polars/cudf_polars/...
cudf_polars source files update SPDX headers, convert many typing.cast targets to string-literal forms, change Scope to enum.StrEnum, normalize environment defaults, and adjust type-ignore comments.
Tests, stubs, and eval cleanup
python/cudf/cudf/tests/..., python/cudf_polars/tests/..., python/cudf/cudf_pandas_tests/..., python/dask_cudf/dask_cudf/tests/..., python/cudf_streaming/cudf_streaming/tests/..., python/pylibcudf/tests/..., python/pylibcudf/pylibcudf/io/experimental/hybrid_scan.pyi, skills/accelerated-computing-cudf/evals/files/...
Tests and eval scripts update raw-string regexes, unused bindings, formatting, and a few typing annotations; the pylibcudf stub enum gains explicit values.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • rapidsai/cudf#22605: Both PRs touch python/cudf_polars/cudf_polars/testing/inject_gpu_engine.py; this one changes the TESTS_TO_SKIP lookup while the referenced PR changes skip entries.
  • rapidsai/cudf#22518: Both PRs modify python/cudf/cudf/core/column/datetime.py around strftime.
  • rapidsai/cudf#22721: Both PRs modify the skill scripts under skills/accelerated-computing-cudf/evals/files/.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between ff34bdb and 8bb3466.

📒 Files selected for processing (103)
  • .pre-commit-config.yaml
  • docs/cudf/source/_ext/PandasCompat.py
  • pyproject.toml
  • python/cudf/cudf/api/types.py
  • python/cudf/cudf/core/_internals/copying.py
  • python/cudf/cudf/core/accessors/string.py
  • python/cudf/cudf/core/column/categorical.py
  • python/cudf/cudf/core/column/column.py
  • python/cudf/cudf/core/column/datetime.py
  • python/cudf/cudf/core/column/decimal.py
  • python/cudf/cudf/core/column/interval.py
  • python/cudf/cudf/core/column/lists.py
  • python/cudf/cudf/core/column/numerical.py
  • python/cudf/cudf/core/column/numerical_base.py
  • python/cudf/cudf/core/column/string.py
  • python/cudf/cudf/core/column/temporal_base.py
  • python/cudf/cudf/core/column/timedelta.py
  • python/cudf/cudf/core/column_accessor.py
  • python/cudf/cudf/core/copy_types.py
  • python/cudf/cudf/core/groupby/groupby.py
  • python/cudf/cudf/core/index.py
  • python/cudf/cudf/core/indexed_frame.py
  • python/cudf/cudf/core/indexing_utils.py
  • python/cudf/cudf/core/multiindex.py
  • python/cudf/cudf/core/reshape.py
  • python/cudf/cudf/core/series.py
  • python/cudf/cudf/core/udf/groupby_utils.py
  • python/cudf/cudf/core/udf/masked_lowering.py
  • python/cudf/cudf/core/udf/utils.py
  • python/cudf/cudf/io/csv.py
  • python/cudf/cudf/pandas/module_accelerator.py
  • python/cudf/cudf/testing/dataset_generator.py
  • python/cudf/cudf/testing/testing.py
  • python/cudf/cudf/tests/dask/test_serialize.py
  • python/cudf/cudf/tests/dataframe/methods/test_diff.py
  • python/cudf/cudf/tests/dataframe/methods/test_query.py
  • python/cudf/cudf/tests/dataframe/methods/test_reductions.py
  • python/cudf/cudf/tests/dataframe/methods/test_sample.py
  • python/cudf/cudf/tests/dataframe/test_attributes.py
  • python/cudf/cudf/tests/general_functions/test_to_numeric.py
  • python/cudf/cudf/tests/general_functions/test_unique.py
  • python/cudf/cudf/tests/groupby/test_apply.py
  • python/cudf/cudf/tests/indexes/multiindex/test_repr.py
  • python/cudf/cudf/tests/input_output/test_avro.py
  • python/cudf/cudf/tests/input_output/test_json.py
  • python/cudf/cudf/tests/input_output/test_orc.py
  • python/cudf/cudf/tests/input_output/test_parquet.py
  • python/cudf/cudf/tests/private_objects/test_extension_compilation.py
  • python/cudf/cudf/tests/reshape/test_concat.py
  • python/cudf/cudf/tests/reshape/test_merge.py
  • python/cudf/cudf/tests/series/accessors/test_list.py
  • python/cudf/cudf/tests/series/accessors/test_str.py
  • python/cudf/cudf/tests/series/methods/test_astype.py
  • python/cudf/cudf/tests/series/methods/test_digitize.py
  • python/cudf/cudf/tests/series/methods/test_map.py
  • python/cudf/cudf/tests/series/methods/test_to_pandas.py
  • python/cudf/cudf/tests/test_flags.py
  • python/cudf/cudf/tests/text/test_text_methods.py
  • python/cudf/cudf_pandas_tests/test_cudf_pandas.py
  • python/cudf/cudf_pandas_tests/test_fast_slow_proxy.py
  • python/cudf/cudf_pandas_tests/third_party_integration_tests/tests/test_cuml.py
  • python/cudf/cudf_pandas_tests/third_party_integration_tests/tests/test_matplotlib.py
  • python/cudf_polars/cudf_polars/callback.py
  • python/cudf_polars/cudf_polars/containers/dataframe.py
  • python/cudf_polars/cudf_polars/containers/datatype.py
  • python/cudf_polars/cudf_polars/dsl/expressions/boolean.py
  • python/cudf_polars/cudf_polars/dsl/expressions/string.py
  • python/cudf_polars/cudf_polars/dsl/expressions/struct.py
  • python/cudf_polars/cudf_polars/dsl/expressions/unary.py
  • python/cudf_polars/cudf_polars/dsl/ir.py
  • python/cudf_polars/cudf_polars/dsl/to_ast.py
  • python/cudf_polars/cudf_polars/dsl/tracing.py
  • python/cudf_polars/cudf_polars/engine/core.py
  • python/cudf_polars/cudf_polars/engine/dask.py
  • python/cudf_polars/cudf_polars/engine/ray.py
  • python/cudf_polars/cudf_polars/engine/spmd.py
  • python/cudf_polars/cudf_polars/streaming/actor_graph/io.py
  • python/cudf_polars/cudf_polars/streaming/actor_graph/nodes.py
  • python/cudf_polars/cudf_polars/streaming/actor_graph/utils.py
  • python/cudf_polars/cudf_polars/streaming/benchmarks/pdsds_queries/q50.py
  • python/cudf_polars/cudf_polars/streaming/explain.py
  • python/cudf_polars/cudf_polars/streaming/shuffle.py
  • python/cudf_polars/cudf_polars/testing/asserts.py
  • python/cudf_polars/cudf_polars/testing/inject_gpu_engine.py
  • python/cudf_polars/pyproject.toml
  • python/cudf_polars/tests/containers/test_datatype.py
  • python/cudf_polars/tests/expressions/test_rolling.py
  • python/cudf_polars/tests/streaming/test_parallel.py
  • python/cudf_polars/tests/streaming/test_sort.py
  • python/cudf_polars/tests/test_config.py
  • python/cudf_polars/tests/test_window_functions.py
  • python/cudf_polars/tests/testing/test_asserts.py
  • python/cudf_streaming/cudf_streaming/tests/test_channel_metadata.py
  • python/dask_cudf/dask_cudf/tests/test_accessor.py
  • python/dask_cudf/dask_cudf/tests/test_core.py
  • python/pylibcudf/pylibcudf/io/experimental/hybrid_scan.pyi
  • python/pylibcudf/pyproject.toml
  • python/pylibcudf/tests/io/test_csv.py
  • python/pylibcudf/tests/test_column_from_array.py
  • python/pylibcudf/tests/test_column_span.py
  • python/pylibcudf/tests/test_string_split_partition.py
  • skills/accelerated-computing-cudf/evals/files/cudf-null-handling/code/null_pipeline.py
  • skills/accelerated-computing-cudf/evals/files/cudf-pivot-melt/code/reshape_analysis.py

Comment thread python/cudf/cudf/core/column/column.py
Comment thread python/cudf/cudf/tests/groupby/test_apply.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.
@vyasr

vyasr commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

Addressed CodeRabbit's review comments:

test_apply.py regex (fixed in a64c619): Good catch — the ruff UP025 autofix converted the match string to a raw string but left the double-backslash escapes intact. In a non-raw string "\\(" produces the string \( which regex interprets as a literal paren. But in a raw string r"\\(" produces \\( which regex interprets as literal-backslash-then-paren — not what we want. Fixed to single backslash r"\(".

column.py dtype None guard (not fixing): The # type: ignore[union-attr] acknowledges that dtype is typed as potentially None, but this is pre-existing code and the None case doesn't appear reachable in practice (the "boolean" + pandas_compatible path requires an explicit dtype from the caller). Adding a None guard would be a behavioral change beyond the scope of this hook-update PR.

Per reviewer feedback, call functions without capturing unused return
values instead of using _prefixed variable names.
@vyasr

vyasr commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot
rapids-bot Bot merged commit ba74d66 into NVIDIA:main Jun 16, 2026
256 of 259 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in cuDF Python Jun 16, 2026
@vyasr
vyasr deleted the feat/pre-commit-update branch June 16, 2026 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cudf.pandas Issues specific to cudf.pandas cudf-polars Issues specific to cudf-polars improvement Improvement / enhancement to an existing function non-breaking Non-breaking change pylibcudf Issues specific to the pylibcudf package Python Affects Python cuDF API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants