googleapis / googleapis/google-cloud-python

Refactor ProtoEnumMeta to use _ignore_ for _pb_options

Đang mở
#16,911 0 bình luận 0 reaction 1 người được giao Được @chalmerlowe nhận Xem trên GitHub
priority: p2 type: cleanup
Ngôn ngữ chính
Python
Star
5.4k
Fork
1.8k
Merge trung bình
3 ngày 4 giờ
Pull request đã merge (30 ngày)
122

Mô tả

We dropped Python 3.7 support and moved to Python 3.9 as the minimum version. This allows us to use the specialized `_ignore_` attribute in `Enum` to ignore `_pb_options` instead of the current manual removal from `_member_names`. Please effect this change to clean up the code in packages/proto-plus/proto/enums.py rather than using the current cumbersome approach.

```
pb_options = "_pb_options"
opts = attrs.pop(pb_options, {})
# This is the only portable way to remove the _pb_options name
# from the enum attrs.
# TODO: Use _ignore_ attribute to ignore _pb_options (Issue #16911)
if pb_options in attrs._member_names:
if isinstance(attrs._member_names, list):
idx = attrs._member_names.index(pb_opt
attrs._member_names.pop(idx)
elif isinstance(attrs._member_names, set):
attrs._member_names.discard(pb_options
else: # Python 3.11.0b3
del attrs._member_names[pb_options]
```

https://github.com/googleapis/google-cloud-python/blob/daa042330755b0db1853b6e45568ead2a3066f4f/packages/proto-plus/pyproject.toml#L23

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.