feat(pandas-gbq): add Ruff format session and implement mypy#17041
feat(pandas-gbq): add Ruff format session and implement mypy#17041chalmerlowe wants to merge 7 commits into
Conversation
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.
There was a problem hiding this comment.
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.
Restored the missing # noqa: F401 on multi-line import in gbq.py to fix flake8 failure.
There was a problem hiding this comment.
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.
…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.
| #missing-data-casting-rules-and-indexing | ||
| """ | ||
| import db_dtypes | ||
| # db-dtypes does not have type hints nor stubs that mypy uses for type checking. |
There was a problem hiding this comment.
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
This PR adds a Ruff-based
formatsession topandas-gbqand implements themypysession based on thegapic-generatortemplate. It also addstype ignoresand descriptive comments for untyped imports in source files, and applies formatting fixes.