Skip to content

chore(generator): centralize mypy configuration and regenerate google-cloud-datastore POC#17408

Draft
chalmerlowe wants to merge 9 commits into
mainfrom
feat/centralize-mypy
Draft

chore(generator): centralize mypy configuration and regenerate google-cloud-datastore POC#17408
chalmerlowe wants to merge 9 commits into
mainfrom
feat/centralize-mypy

Conversation

@chalmerlowe

@chalmerlowe chalmerlowe commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Note

This is a POC for discussion. It is incomplete and is intended to get buy-in on the general process. Additional steps will be required to:

  • generate the remaining generated packages
  • generate and/or post process hybrid packages

This work:

  • Adds a centralized mypy.ini file at the root of the repository.
  • Updated GAPIC generator templates to omit local mypy.ini and dynamically resolve the root config via a MYPY_CONFIG_FILE constant.
  • Removes mypy.ini replacements from datastore-integration.yaml post-processing.
  • Regenerates google-cloud-datastore using the updated generator configurations to serve as a proof of concept.

Note

Work on strictly handwritten libraries is outside the scope of this PR and can be found here: #17409

@chalmerlowe chalmerlowe changed the title feat(generator): centralize mypy configuration and regenerate google-cloud-datastore POC chore(generator): centralize mypy configuration and regenerate google-cloud-datastore POC Jun 9, 2026

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

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.

Code Review

This pull request consolidates package-specific mypy.ini configurations into a single root mypy.ini file, updates the noxfile.py templates to reference this root configuration, and bumps several dependency versions (such as google-api-core, proto-plus, and protobuf) across the Datastore package. Feedback on the changes highlights that the exclude paths in the new mypy.ini should use (^|/) instead of ^ to ensure they match correctly when executed from subdirectories. Additionally, the strictness flags under [mypy-google.cloud.bigtable.*] are redundant due to ignore_errors = True and should be moved to the [mypy-google.cloud.bigtable.data.*] section.

Comment thread mypy.ini
Comment on lines +12 to +16
exclude = (?x)(
^third_party/
| tests/unit/resources/
| tests/unit/gapic/
)

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.

medium

The exclude pattern uses ^third_party/ which only matches if third_party/ is at the root of the search path. When running mypy from individual package directories (e.g., via nox), or if a package has its own nested third_party directory, this anchor will prevent it from matching. Using (^|/) makes the exclusion patterns robust and consistent regardless of whether mypy is executed from the repository root or from a package subdirectory.

exclude = (?x)(
    (^|/)third_party/
  | (^|/)tests/unit/resources/
  | (^|/)tests/unit/gapic/
  )

Comment thread mypy.ini
Comment on lines +60 to +67
[mypy-google.cloud.bigtable.*]
check_untyped_defs = True
warn_unreachable = True
disallow_any_generics = True
ignore_errors = True

[mypy-google.cloud.bigtable.data.*]
ignore_errors = False

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.

medium

Setting strictness flags like check_untyped_defs, warn_unreachable, and disallow_any_generics under [mypy-google.cloud.bigtable.*] is redundant because ignore_errors = True is also set for that pattern, which silences all errors. If these strictness flags were intended to apply to the non-ignored [mypy-google.cloud.bigtable.data.*] submodule, they should be moved to that section instead.

[mypy-google.cloud.bigtable.*]
ignore_errors = True

[mypy-google.cloud.bigtable.data.*]
check_untyped_defs = True
warn_unreachable = True
disallow_any_generics = True
ignore_errors = False

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.

1 participant