Skip to content

feat(pandas-gbq): add Ruff format session and implement mypy#17041

Open
chalmerlowe wants to merge 7 commits into
mainfrom
feat/add-format-pandas-gbq
Open

feat(pandas-gbq): add Ruff format session and implement mypy#17041
chalmerlowe wants to merge 7 commits into
mainfrom
feat/add-format-pandas-gbq

Conversation

@chalmerlowe
Copy link
Copy Markdown
Contributor

@chalmerlowe chalmerlowe commented May 12, 2026

This PR adds a Ruff-based format session to pandas-gbq and implements the mypy session based on the gapic-generator template. It also adds type ignores and descriptive comments for untyped imports in source files, and applies formatting fixes.

Added Ruff-based format session and implemented mypy session based on the gold standard template.
…/flake8

Added type ignores for untyped imports and descriptive comments to explain them to junior engineers.
Formatted files using Ruff and Black to resolve linting failures.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request replaces isort and black with ruff for code formatting and import sorting, and enables the mypy type-checking session in the nox configuration. To support type checking, several imports have been annotated with # type: ignore[import-untyped]. Additionally, the PR includes general import reordering and minor string formatting cleanups. Review feedback identifies that the specified ruff version does not exist on PyPI and that the format session uses an undefined variable, UNIT_TEST_PYTHON_VERSIONS, which will lead to a NameError during execution.

Comment thread packages/pandas-gbq/noxfile.py
Comment thread packages/pandas-gbq/noxfile.py
Restored the missing # noqa: F401 on multi-line import in gbq.py to fix flake8 failure.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request replaces isort and black with ruff for code formatting and import sorting in the noxfile.py. It also enables the mypy type-checking session, which was previously skipped, by adding necessary type stubs and type: ignore comments for untyped dependencies. Additionally, imports across several files have been reorganized, and test code has been modernized with parenthesized context managers. A critical issue was identified regarding an invalid version number for ruff that would cause installation failures in the CI environment.

Comment thread packages/pandas-gbq/noxfile.py
…connector

Resolved 11 mypy errors by adding assertions, checking for None, using Any for tqdm, and converting tuple to list.
Replaced asserts with typing.cast and explicit TypeError checks to follow team policy.
Formatted pandas.py and load/core.py with Black to resolve linting failures.
@chalmerlowe chalmerlowe marked this pull request as ready for review May 12, 2026 13:57
@chalmerlowe chalmerlowe requested review from a team as code owners May 12, 2026 13:57
@chalmerlowe chalmerlowe requested review from GarrettWu and removed request for a team May 12, 2026 13:57
#missing-data-casting-rules-and-indexing
"""
import db_dtypes
# db-dtypes does not have type hints nor stubs that mypy uses for type checking.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please can you include a link to a tracking bug in google-cloud-python to follow up on this? Applies throughout for all the packages in this PR that don't have type hints

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants