Skip to content

Update mypy configuration to check against polars#19072

Merged
rapids-bot[bot] merged 3 commits intorapidsai:branch-25.08from
TomAugspurger:tom/mypy-config-fix
Jun 5, 2025
Merged

Update mypy configuration to check against polars#19072
rapids-bot[bot] merged 3 commits intorapidsai:branch-25.08from
TomAugspurger:tom/mypy-config-fix

Conversation

@TomAugspurger
Copy link
Copy Markdown
Contributor

This updates our mypy configuration to be a bit stricter / more thorough in two ways:

  1. It follows imports for polars (i.e. doesn't assign polars types Any, which always type checks successfully even if incorrect)
  2. It checks the types in python/cudf_polars/tests

This will help catch issues like https://github.com/rapidsai/cudf/pull/18797/files/981a25b7fa7968395958b9fae32c71bc3f548eda#r2089470041, which slipped through because by not following imports any types from polars are considered Any and so always type check successfully.

Note that I haven't disallowed untyped defs in the cudf_polars tests. I can do that if people want to require types in the tests.

@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented Jun 3, 2025

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@github-actions github-actions Bot added Python Affects Python cuDF API. cudf-polars Issues specific to cudf-polars labels Jun 3, 2025
@GPUtester GPUtester moved this to In Progress in cuDF Python Jun 3, 2025
This updates our mypy configuration to follow imports for polars. This
will help catch issues like
https://github.com/rapidsai/cudf/pull/18797/files/981a25b7fa7968395958b9fae32c71bc3f548eda#r2089470041,
which slipped through because by not following imports any types from
polars are considered Any.
@TomAugspurger TomAugspurger force-pushed the tom/mypy-config-fix branch from 92914db to 109db3f Compare June 3, 2025 15:43
Comment thread python/cudf_polars/cudf_polars/typing/__init__.py
@TomAugspurger TomAugspurger added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Jun 3, 2025
@TomAugspurger TomAugspurger marked this pull request as ready for review June 5, 2025 14:25
@TomAugspurger TomAugspurger requested review from a team as code owners June 5, 2025 14:25
Copy link
Copy Markdown
Member

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

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

Nice!

Mostly deferring to @mroeschke 's review here, but the idea seems sound to me and I appreciate the use of specific warning codes in the # type: ignore comments.

@TomAugspurger
Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot rapids-bot Bot merged commit f390a0a into rapidsai:branch-25.08 Jun 5, 2025
94 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in cuDF Python Jun 5, 2025
@TomAugspurger TomAugspurger deleted the tom/mypy-config-fix branch June 5, 2025 17:14
rapids-bot Bot pushed a commit that referenced this pull request Nov 12, 2025
#19072 made a lot of the necessary fixes, but polars was not actually added to the pre-commit mypy environment so we haven't been checking since then. As a result, some new issues have crept in, and #20272 removed various ignores that are required for polars type safety but mypy didn't know that without polars available.

Authors:
  - Vyas Ramasubramani (https://github.com/vyasr)

Approvers:
  - GALI PREM SAGAR (https://github.com/galipremsagar)
  - Bradley Dice (https://github.com/bdice)
  - Tom Augspurger (https://github.com/TomAugspurger)
  - Matthew Murray (https://github.com/Matt711)

URL: #20563
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants