Type match with collections.abc.Collection and some exclusions #152
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this Pull Request accomplish?
Updates the gRPC conversion logic to determine if something is a "collection" by checking if it's an instance of
collections.abc.Collection
, but not an instance of several other types that are technically collections but are handled with a custom converter.Exclusions:
str
: Has a separate converterbytes
: Has a separate converterenum.Enum
: Converted as intsdict
: Not a valid type to convertni.protobuf.types.Vector
: Has a separate converterWhy should this Pull Request be merged?
AB#3175632
What testing has been done?
Unit tests, mypy, pyright, styleguide
Previous RFC Comments
This is a Request for Comment (at least for now) PR addressing this research item about using
collections.abc
instead oflist, set, frozen_set, etc.
to determine collections for conversion.AB#3175632
The question to answer here is whether the implementation in this PR is better and/or more maintainable than keeping a "inclusion" list of the types of collections we support. Note that I do not know if the exclusion list is complete, but it does satisfy the unit tests that were already written. We'll have to maintain the exclusion list, so we'll have to decide whether that's easier than maintaining the inclusion list.