chore(generator): centralize mypy configuration and regenerate google-cloud-datastore POC#17408
chore(generator): centralize mypy configuration and regenerate google-cloud-datastore POC#17408chalmerlowe wants to merge 9 commits into
Conversation
There was a problem hiding this comment.
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.
| exclude = (?x)( | ||
| ^third_party/ | ||
| | tests/unit/resources/ | ||
| | tests/unit/gapic/ | ||
| ) |
There was a problem hiding this comment.
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/
)
| [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 |
There was a problem hiding this comment.
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
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:
This work:
mypy.inifile at the root of the repository.MYPY_CONFIG_FILEconstant.mypy.inireplacements fromdatastore-integration.yamlpost-processing.google-cloud-datastoreusing 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