Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit143b042

Browse files
authored
API Core: fix pytype build (#6873)
* Run 'pytype' only over the 'google/' directory.* Ignore 'pytype_output/' derived files.* Remove spurious 'MutableMapping.register' call.'pytype' chokes on it, but the 'Policy' class already derives from'MutableMapping', so the call is a no-op.* Silence deprecation spew during IAM unit tests.
1 parent7a15ffc commit143b042

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,4 @@ generated_python/
6969
cloud-bigtable-client/
7070
googleapis-pb/
7171
grpc_python_venv/
72+
pytype_output/

‎api_core/google/api_core/iam.py‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,3 @@ def to_api_repr(self):
243243
delresource["bindings"]
244244

245245
returnresource
246-
247-
248-
collections_abc.MutableMapping.register(Policy)

‎api_core/setup.cfg‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ universal = 1
44
[pytype]
55
python_version = 3.6
66
inputs =
7-
.
7+
google/
88
exclude =
99
tests/

‎api_core/tests/unit/test_iam.py‎

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,12 @@ def test_owners_setter(self):
9090
MEMBER="user:phred@example.com"
9191
expected=set([MEMBER])
9292
policy=self._make_one()
93-
withwarnings.catch_warnings():
94-
warnings.simplefilter("always")
93+
94+
withwarnings.catch_warnings(record=True)aswarned:
9595
policy.owners= [MEMBER]
96+
97+
warning,=warned
98+
assertwarning.categoryisDeprecationWarning
9699
assertpolicy[OWNER_ROLE]==expected
97100

98101
deftest_editors_getter(self):
@@ -111,9 +114,12 @@ def test_editors_setter(self):
111114
MEMBER="user:phred@example.com"
112115
expected=set([MEMBER])
113116
policy=self._make_one()
114-
withwarnings.catch_warnings():
115-
warnings.simplefilter("always")
117+
118+
withwarnings.catch_warnings(record=True)aswarned:
116119
policy.editors= [MEMBER]
120+
121+
warning,=warned
122+
assertwarning.categoryisDeprecationWarning
117123
assertpolicy[EDITOR_ROLE]==expected
118124

119125
deftest_viewers_getter(self):
@@ -132,9 +138,12 @@ def test_viewers_setter(self):
132138
MEMBER="user:phred@example.com"
133139
expected=set([MEMBER])
134140
policy=self._make_one()
135-
withwarnings.catch_warnings():
136-
warnings.simplefilter("always")
141+
142+
withwarnings.catch_warnings(record=True)aswarned:
137143
policy.viewers= [MEMBER]
144+
145+
warning,=warned
146+
assertwarning.categoryisDeprecationWarning
138147
assertpolicy[VIEWER_ROLE]==expected
139148

140149
deftest_user(self):
@@ -240,17 +249,20 @@ def test_to_api_repr_binding_wo_members(self):
240249
assertpolicy.to_api_repr()== {}
241250

242251
deftest_to_api_repr_binding_w_duplicates(self):
252+
importwarnings
243253
fromgoogle.api_core.iamimportOWNER_ROLE
244254

245255
OWNER="group:cloud-logs@google.com"
246256
policy=self._make_one()
247-
policy.owners= [OWNER,OWNER]
257+
withwarnings.catch_warnings(record=True):
258+
policy.owners= [OWNER,OWNER]
248259
assertpolicy.to_api_repr()== {
249260
"bindings": [{"role":OWNER_ROLE,"members": [OWNER]}]
250261
}
251262

252263
deftest_to_api_repr_full(self):
253264
importoperator
265+
importwarnings
254266
fromgoogle.api_core.iamimportOWNER_ROLE,EDITOR_ROLE,VIEWER_ROLE
255267

256268
OWNER1="group:cloud-logs@google.com"
@@ -265,9 +277,10 @@ def test_to_api_repr_full(self):
265277
{"role":VIEWER_ROLE,"members": [VIEWER1,VIEWER2]},
266278
]
267279
policy=self._make_one("DEADBEEF",17)
268-
policy.owners= [OWNER1,OWNER2]
269-
policy.editors= [EDITOR1,EDITOR2]
270-
policy.viewers= [VIEWER1,VIEWER2]
280+
withwarnings.catch_warnings(record=True):
281+
policy.owners= [OWNER1,OWNER2]
282+
policy.editors= [EDITOR1,EDITOR2]
283+
policy.viewers= [VIEWER1,VIEWER2]
271284
resource=policy.to_api_repr()
272285
assertresource["etag"]=="DEADBEEF"
273286
assertresource["version"]==17

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp