Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a py.typed file for submodule #240

Closed
crwilcox opened this issue Oct 12, 2021 · 4 comments · Fixed by #241 or #251
Closed

Add a py.typed file for submodule #240

crwilcox opened this issue Oct 12, 2021 · 4 comments · Fixed by #241 or #251
Assignees
Labels
api: datastore Issues related to the googleapis/python-datastore API. type: cleanup An internal cleanup or hygiene concern.

Comments

@crwilcox
Copy link
Contributor

crwilcox commented Oct 12, 2021

To be in accordance with PEP 561 we should add a py.typed file to google/cloud/datastore/py.typed

The file can be empty but does need to be present for some type checkers.

@product-auto-label product-auto-label bot added the api: datastore Issues related to the googleapis/python-datastore API. label Oct 12, 2021
@crwilcox
Copy link
Contributor Author

Reopening as to be done, we ought to ensure passage. Do note, you may need to run mypy, pyright, pytype against our samples before merging. It will ensure that we aren't exposing users to failing type checks.

Ideally we would add this to CI as well, to avoid future breakage.

@crwilcox crwilcox reopened this Oct 13, 2021
@crwilcox crwilcox self-assigned this Oct 13, 2021
@meredithslota meredithslota added the type: cleanup An internal cleanup or hygiene concern. label Oct 13, 2021
@crwilcox
Copy link
Contributor Author

TODO:
currently the code as merged is validating the package, google.cloud.datastore.

We want to evaluate mypy against google and tests

Once https://www.github.com/googleapis/gapic-generator-python/issues/1026 is addressed, we should be unblocked to wrap this up.

@crwilcox crwilcox assigned kolea2 and unassigned crwilcox Oct 18, 2021
@tseaver
Copy link
Contributor

tseaver commented Nov 3, 2021

I have a WIP locally which passes.

$ .nox/mypy/bin/mypy google/ tests
Success: no issues found in 66 source files

In addition to tweaking noxfile.py to install additional types-* packages, I needed to apply the changes which should be generated by these two gapic-generator-python PRs:

However, there is another issue which is un-addressed by those PRs: the generated code for the datastore_admin_v1 clients declares invalid / unknown types for the labels parameters to import_entities and export_entites:

$ .nox/mypy/bin/mypy google/
google/cloud/datastore_admin_v1/services/datastore_admin/client.py:384: error: Name "datastore_admin.ExportEntitiesRequest.LabelsEntry" is not defined
google/cloud/datastore_admin_v1/services/datastore_admin/client.py:523: error: Name "datastore_admin.ImportEntitiesRequest.LabelsEntry" is not defined
google/cloud/datastore_admin_v1/services/datastore_admin/async_client.py:209: error: Name "datastore_admin.ExportEntitiesRequest.LabelsEntry" is not defined
google/cloud/datastore_admin_v1/services/datastore_admin/async_client.py:347: error: Name "datastore_admin.ImportEntitiesRequest.LabelsEntry" is not defined

By my reading of the protobuf definition, those parameters should be typed as Dict[str, str], and in fact that makes mypy happy.

@tseaver
Copy link
Contributor

tseaver commented Nov 3, 2021

The LabelsEntry bug is due to googleapis/gapic-generator-python#689.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the googleapis/python-datastore API. type: cleanup An internal cleanup or hygiene concern.
Projects
None yet
4 participants