googleapis / googleapis/google-cloud-python

Ensure mypy passes for all packages with `--check-untyped-defs`

Đang mở
#16,083 0 bình luận 1 reaction 0 người được giao Xem trên GitHub
priority: p3 type: cleanup
Ngôn ngữ chính
Python
Star
5.4k
Fork
1.8k
Merge trung bình
3 ngày 4 giờ
Pull request đã merge (30 ngày)
122

Mô tả

In PR https://github.com/googleapis/google-cloud-python/pull/16079, there were several mypy failures when `--check-untyped-defs` was added to the `mypy` command. These failures are in hybrid libraries, but more specifically the handwritten files in these libraries. The `noxfile.py` file is automatically generated for hybrid libraries which is how `--check-untyped-defs` was turned on for the hybrid libraries.

See the build log [here](https://github.com/googleapis/google-cloud-python/actions/runs/22976224095/job/66705373785).

Example failure

```
2026-03-11T22:14:04.4510210Z ~/work/google-cloud-python/google-cloud-python/packages/google-cloud-bigquery-storage ~/work/google-cloud-python/google-cloud-python
2026-03-11T22:14:04.5854802Z nox > Running session mypy-3.14
2026-03-11T22:14:04.5860181Z nox > Creating virtual environment (virtualenv) using python3.14 in .nox/mypy-3-14
2026-03-11T22:14:04.8461731Z nox > python -m pip install 'mypy<1.16.0' types-requests types-protobuf pandas-stubs
2026-03-11T22:14:10.7173130Z nox > python -m pip install '.[fastavro]'
2026-03-11T22:14:16.2114683Z nox > mypy -p google --check-untyped-defs
2026-03-11T22:14:16.3367918Z mypy.ini: [mypy-google.iam.*]: Per-module sections should only specify per-module flags (explicit_package_bases, incremental)
2026-03-11T22:15:08.0802838Z .nox/mypy-3-14/lib/python3.14/site-packages/google/cloud/bigquery_storage_v1/reader.py:150: error: Item "None" of "Any | None" has no attribute "__iter__" (not iterable) [union-attr]
2026-03-11T22:15:08.0806274Z .nox/mypy-3-14/lib/python3.14/site-packages/google/cloud/bigquery_storage_v1/reader.py:451: error: Item "None" of "Any | None" has no attribute "empty_table" [union-attr]
2026-03-11T22:15:08.0807929Z .nox/mypy-3-14/lib/python3.14/site-packages/google/cloud/bigquery_storage_v1/reader.py:553: error: Argument 1 to "next" has incompatible type "Any | None"; expected "SupportsNext[Any]" [arg-type]
2026-03-11T22:15:08.0809570Z .nox/mypy-3-14/lib/python3.14/site-packages/google/cloud/bigquery_storage_v1/reader.py:711: error: Incompatible types in assignment (expression has type "Series[Any]", target has type "list[Any]") [assignment]
2026-03-11T22:15:08.0811203Z .nox/mypy-3-14/lib/python3.14/site-packages/google/cloud/bigquery_storage_v1/reader.py:728: error: Argument 1 has incompatible type "Any | None"; expected "str | list[Any] | dict[Any, Any]" [arg-type]
2026-03-11T22:15:08.0812495Z .nox/mypy-3-14/lib/python3.14/site-packages/google/cloud/bigquery_storage_v1/reader.py:751: error: Too few arguments [call-arg]
2026-03-11T22:15:08.0813984Z .nox/mypy-3-14/lib/python3.14/site-packages/google/cloud/bigquery_storage_v1/reader.py:751: error: Argument 2 has incompatible type "Any | None"; expected "str | list[Any] | dict[Any, Any]" [arg-type]
2026-03-11T22:15:09.6739206Z .nox/mypy-3-14/lib/python3.14/site-packages/google/cloud/bigquery_storage_v1/client.py:52: error: Signature of "read_rows" incompatible with supertype "BigQueryReadClient" [override]
2026-03-11T22:15:09.6740790Z .nox/mypy-3-14/lib/python3.14/site-packages/google/cloud/bigquery_storage_v1/client.py:52: note: Superclass:
2026-03-11T22:15:09.6743230Z .nox/mypy-3-14/lib/python3.14/site-packages/google/cloud/bigquery_storage_v1/client.py:52: note: def read_rows(self, request: ReadRowsRequest | dict[Any, Any] | None = ..., *, read_stream: str | None = ..., offset: int | None = ..., retry: Retry | _MethodDefault | None = ..., timeout: float | object = ..., metadata: Sequence[tuple[str, str | bytes]] = ...) -> Iterable[ReadRowsResponse]
2026-03-11T22:15:09.6745217Z .nox/mypy-3-14/lib/python3.14/site-packages/google/cloud/bigquery_storage_v1/client.py:52: note: Subclass:
2026-03-11T22:15:09.6747140Z .nox/mypy-3-14/lib/python3.14/site-packages/google/cloud/bigquery_storage_v1/client.py:52: note: def read_rows(self, name: Any, offset: Any = ..., retry: Any = ..., timeout: Any = ..., metadata: Any = ..., retry_delay_callback: Any = ...) -> Any
2026-03-11T22:15:10.9410241Z .nox/mypy-3-14/lib/python3.14/site-packages/google/cloud/bigquery_storage_v1beta2/client.py:54: error: Signature of "read_rows" incompatible with supertype "BigQueryReadClient" [override]
2026-03-11T22:15:10.9411561Z .nox/mypy-3-14/lib/python3.14/site-packages/google/cloud/bigquery_storage_v1beta2/client.py:54: note: Superclass:
2026-03-11T22:15:10.9413591Z .nox/mypy-3-14/lib/python3.14/site-packages/google/cloud/bigquery_storage_v1beta2/client.py:54: note: def read_rows(self, request: ReadRowsRequest | dict[Any, Any] | None = ..., *, read_stream: str | None = ..., offset: int | None = ..., retry: Retry | _MethodDefault | None = ..., timeout: float | object = ..., metadata: Sequence[tuple[str, str | bytes]] = ...) -> Iterable[ReadRowsResponse]
2026-03-11T22:15:10.9415850Z .nox/mypy-3-14/lib/python3.14/site-packages/google/cloud/bigquery_storage_v1beta2/client.py:54: note: Subclass:
2026-03-11T22:15:10.9417258Z .nox/mypy-3-14/lib/python3.14/site-packages/google/cloud/bigquery_storage_v1beta2/client.py:54: note: def read_rows(self, name: Any, offset: Any = ..., retry: Any = ..., timeout: Any = ..., metadata: Any = ..., retry_delay_callback: Any = ...) -> Any
2026-03-11T22:15:12.1840694Z Found 9 errors in 3 files (checked 87 source files)
2026-03-11T22:15:12.2047664Z nox > Command mypy -p google --check-untyped-defs failed with exit code 1
2026-03-11T22:15:12.2048654Z nox > Session mypy-3.14 failed.
```

This bug tracks adding `--check-untyped-defs` to the `mypy` command for all packages, including the handwritten ones.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.