fix: fix mypy errors in rest.py#1599
Conversation
| {% 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.
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.
I removed Any . PTAL
| {% 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.
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.
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.....
This reverts commit 2f07463.
Fixes #1600
Also addresses mypy error in golden file
credentials/google/iam/credentials_v1/types/iamcredentials.pyhttps://github.com/googleapis/gapic-generator-python/blob/main/tests/integration/goldens/credentials/google/iam/credentials_v1/types/iamcredentials.py#L18