-
Notifications
You must be signed in to change notification settings - Fork 69
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
fix: fix mypy errors in rest.py #1599
Conversation
@@ -269,7 +269,7 @@ class {{service.name}}RestTransport({{service.name}}Transport): | |||
|
|||
{% if not method.client_streaming %} | |||
{% if method.input.required_fields %} | |||
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { | |||
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the whole purpose of typing
is to provide type hints, then isn't the use of Any
defeating the purpose? Is there a more narrow type hint we could provide? (I see that the error message in [1] expects as the map value the type "Dict[<nothing>, <nothing>]"
)
[1] https://github.com/googleapis/python-bigtable/actions/runs/4196460916/jobs/7277462654
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed Any
. PTAL
@@ -269,7 +269,7 @@ class {{service.name}}RestTransport({{service.name}}Transport): | |||
|
|||
{% if not method.client_streaming %} | |||
{% if method.input.required_fields %} | |||
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = { | |||
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But only checking for Dict
does even less type checking than Dict[str, Any]
, right, so what's the point? I was wondering whether we could have the str
check on the key but also make the type check tighter than just an Any
. Does that make sense?
The more I think about it, though, the more I wonder whether it's a sensible question. I guess each required field can be of any proto-derived type, and there may be multiple required fields, so at best we could check for the union of the types of the required fields in the request message. Hmmmm.... Maybe you're right, Dict[str,Any]
is the most sensible. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought about it some more. I suggest reverting your last commit and going back to Dict[str,Any]
(sorry!) unless there's any way to make the Any
more specific, which I'm thinking there isn't without a lot more work for arguably small benefit.....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
This reverts commit 2f07463.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. Thanks!
Fixes #1600
Also addresses mypy error in golden file
credentials/google/iam/credentials_v1/types/iamcredentials.py
https://github.com/googleapis/gapic-generator-python/blob/main/tests/integration/goldens/credentials/google/iam/credentials_v1/types/iamcredentials.py#L18