Skip to content

Commit f4a2f7c

Browse files
committed
blacken
1 parent d7bbd2c commit f4a2f7c

4 files changed

Lines changed: 50 additions & 50 deletions

File tree

api_core/google/api_core/iam.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,7 @@ def user(email):
296296
DEPRECATED: set the role `user:{email}` in the binding instead.
297297
"""
298298
warnings.warn(
299-
_FACTORY_DEPRECATED_MSG.format("user:{email}"),
300-
DeprecationWarning,
299+
_FACTORY_DEPRECATED_MSG.format("user:{email}"), DeprecationWarning,
301300
)
302301
return "user:%s" % (email,)
303302

@@ -332,8 +331,7 @@ def group(email):
332331
DEPRECATED: set the role `group:{email}` in the binding instead.
333332
"""
334333
warnings.warn(
335-
_FACTORY_DEPRECATED_MSG.format("group:{email}"),
336-
DeprecationWarning,
334+
_FACTORY_DEPRECATED_MSG.format("group:{email}"), DeprecationWarning,
337335
)
338336
return "group:%s" % (email,)
339337

@@ -350,8 +348,7 @@ def domain(domain):
350348
DEPRECATED: set the role `domain:{email}` in the binding instead.
351349
"""
352350
warnings.warn(
353-
_FACTORY_DEPRECATED_MSG.format("domain:{email}"),
354-
DeprecationWarning,
351+
_FACTORY_DEPRECATED_MSG.format("domain:{email}"), DeprecationWarning,
355352
)
356353
return "domain:%s" % (domain,)
357354

@@ -365,8 +362,7 @@ def all_users():
365362
DEPRECATED: set the role `allUsers` in the binding instead.
366363
"""
367364
warnings.warn(
368-
_FACTORY_DEPRECATED_MSG.format("allUsers"),
369-
DeprecationWarning,
365+
_FACTORY_DEPRECATED_MSG.format("allUsers"), DeprecationWarning,
370366
)
371367
return "allUsers"
372368

@@ -380,8 +376,7 @@ def authenticated_users():
380376
DEPRECATED: set the role `allAuthenticatedUsers` in the binding instead.
381377
"""
382378
warnings.warn(
383-
_FACTORY_DEPRECATED_MSG.format("allAuthenticatedUsers"),
384-
DeprecationWarning,
379+
_FACTORY_DEPRECATED_MSG.format("allAuthenticatedUsers"), DeprecationWarning,
385380
)
386381
return "allAuthenticatedUsers"
387382

@@ -401,7 +396,7 @@ def from_api_repr(cls, resource):
401396
policy.bindings = resource.get("bindings", [])
402397

403398
for binding in policy.bindings:
404-
binding['members'] = set(binding.get("members", ()))
399+
binding["members"] = set(binding.get("members", ()))
405400

406401
return policy
407402

api_core/tests/unit/test_iam.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ def test___getitem___with_conditions(self):
6464
USER = "user:phred@example.com"
6565
CONDITION = {"expression": "2 > 1"}
6666
policy = self._make_one("DEADBEEF", 1)
67-
policy.bindings = [{"role": "role/reader", "members": [USER], "condition": CONDITION}]
67+
policy.bindings = [
68+
{"role": "role/reader", "members": [USER], "condition": CONDITION}
69+
]
6870
with pytest.raises(InvalidOperationException, match=_DICT_ACCESS_MSG):
6971
policy["role/reader"]
7072

@@ -86,9 +88,11 @@ def test___setitem___with_conditions(self):
8688
USER = "user:phred@example.com"
8789
CONDITION = {"expression": "2 > 1"}
8890
policy = self._make_one("DEADBEEF", 1)
89-
policy.bindings = [{"role": "role/reader", "members": [USER], "condition": CONDITION}]
91+
policy.bindings = [
92+
{"role": "role/reader", "members": [USER], "condition": CONDITION}
93+
]
9094
with pytest.raises(InvalidOperationException, match=_DICT_ACCESS_MSG):
91-
policy['role/reader'] = ["user:phred@example.com"]
95+
policy["role/reader"] = ["user:phred@example.com"]
9296

9397
def test___delitem___hit(self):
9498
policy = self._make_one()
@@ -111,9 +115,11 @@ def test___delitem___with_conditions(self):
111115
USER = "user:phred@example.com"
112116
CONDITION = {"expression": "2 > 1"}
113117
policy = self._make_one("DEADBEEF", 1)
114-
policy.bindings = [{"role": "role/reader", "members": [USER], "condition": CONDITION}]
118+
policy.bindings = [
119+
{"role": "role/reader", "members": [USER], "condition": CONDITION}
120+
]
115121
with pytest.raises(InvalidOperationException, match=_DICT_ACCESS_MSG):
116-
del policy['role/reader']
122+
del policy["role/reader"]
117123

118124
def test_bindings_property(self):
119125
USER = "user:phred@example.com"
@@ -143,7 +149,7 @@ def test_owners_setter(self):
143149
with warnings.catch_warnings(record=True) as warned:
144150
policy.owners = [MEMBER]
145151

146-
warning, = warned
152+
(warning,) = warned
147153
assert warning.category is DeprecationWarning
148154
assert policy[OWNER_ROLE] == expected
149155

@@ -167,7 +173,7 @@ def test_editors_setter(self):
167173
with warnings.catch_warnings(record=True) as warned:
168174
policy.editors = [MEMBER]
169175

170-
warning, = warned
176+
(warning,) = warned
171177
assert warning.category is DeprecationWarning
172178
assert policy[EDITOR_ROLE] == expected
173179

@@ -191,7 +197,7 @@ def test_viewers_setter(self):
191197
with warnings.catch_warnings(record=True) as warned:
192198
policy.viewers = [MEMBER]
193199

194-
warning, = warned
200+
(warning,) = warned
195201
assert warning.category is DeprecationWarning
196202
assert policy[VIEWER_ROLE] == expected
197203

@@ -204,7 +210,7 @@ def test_user(self):
204210
with warnings.catch_warnings(record=True) as warned:
205211
assert policy.user(EMAIL) == MEMBER
206212

207-
warning, = warned
213+
(warning,) = warned
208214
assert warning.category is DeprecationWarning
209215

210216
def test_service_account(self):
@@ -216,7 +222,7 @@ def test_service_account(self):
216222
with warnings.catch_warnings(record=True) as warned:
217223
assert policy.service_account(EMAIL) == MEMBER
218224

219-
warning, = warned
225+
(warning,) = warned
220226
assert warning.category is DeprecationWarning
221227

222228
def test_group(self):
@@ -228,7 +234,7 @@ def test_group(self):
228234
with warnings.catch_warnings(record=True) as warned:
229235
assert policy.group(EMAIL) == MEMBER
230236

231-
warning, = warned
237+
(warning,) = warned
232238
assert warning.category is DeprecationWarning
233239

234240
def test_domain(self):
@@ -240,7 +246,7 @@ def test_domain(self):
240246
with warnings.catch_warnings(record=True) as warned:
241247
assert policy.domain(DOMAIN) == MEMBER
242248

243-
warning, = warned
249+
(warning,) = warned
244250
assert warning.category is DeprecationWarning
245251

246252
def test_all_users(self):
@@ -250,7 +256,7 @@ def test_all_users(self):
250256
with warnings.catch_warnings(record=True) as warned:
251257
assert policy.all_users() == "allUsers"
252258

253-
warning, = warned
259+
(warning,) = warned
254260
assert warning.category is DeprecationWarning
255261

256262
def test_authenticated_users(self):
@@ -260,7 +266,7 @@ def test_authenticated_users(self):
260266
with warnings.catch_warnings(record=True) as warned:
261267
assert policy.authenticated_users() == "allAuthenticatedUsers"
262268

263-
warning, = warned
269+
(warning,) = warned
264270
assert warning.category is DeprecationWarning
265271

266272
def test_from_api_repr_only_etag(self):

bigtable/google/cloud/bigtable/policy.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,7 @@ def from_pb(cls, policy_pb):
156156

157157
policy.bindings = bindings = []
158158
for binding_pb in policy_pb.bindings:
159-
binding = {
160-
"role": binding_pb.role,
161-
"members": set(binding_pb.members)
162-
}
159+
binding = {"role": binding_pb.role, "members": set(binding_pb.members)}
163160
condition = binding_pb.condition
164161
if condition and condition.expression:
165162
binding["condition"] = {
@@ -186,7 +183,8 @@ def to_pb(self):
186183
policy_pb2.Binding(
187184
role=binding["role"],
188185
members=sorted(binding["members"]),
189-
condition=binding.get("condition"))
186+
condition=binding.get("condition"),
187+
)
190188
for binding in self.bindings
191189
if binding["members"]
192190
],

bigtable/tests/unit/test_policy.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -137,20 +137,18 @@ def test_from_pb_with_condition(self):
137137
VERSION = 3
138138
members = ["serviceAccount:service_acc1@test.com", "user:user1@test.com"]
139139
empty = frozenset()
140-
BINDINGS = [{
141-
"role": BIGTABLE_ADMIN_ROLE,
142-
"members": members,
143-
"condition": {
144-
"title": "request_time",
145-
"description": "Requests made before 2021-01-01T00:00:00Z",
146-
"expression": "request.time < timestamp(\"2021-01-01T00:00:00Z\")"
140+
BINDINGS = [
141+
{
142+
"role": BIGTABLE_ADMIN_ROLE,
143+
"members": members,
144+
"condition": {
145+
"title": "request_time",
146+
"description": "Requests made before 2021-01-01T00:00:00Z",
147+
"expression": 'request.time < timestamp("2021-01-01T00:00:00Z")',
148+
},
147149
}
148-
}]
149-
message = policy_pb2.Policy(
150-
etag=ETAG,
151-
version=VERSION,
152-
bindings=BINDINGS,
153-
)
150+
]
151+
message = policy_pb2.Policy(etag=ETAG, version=VERSION, bindings=BINDINGS,)
154152
klass = self._get_target_class()
155153
policy = klass.from_pb(message)
156154
self.assertEqual(policy.etag, ETAG)
@@ -206,22 +204,25 @@ def test_to_pb_with_condition(self):
206204
condition = {
207205
"title": "request_time",
208206
"description": "Requests made before 2021-01-01T00:00:00Z",
209-
"expression": "request.time < timestamp(\"2021-01-01T00:00:00Z\")"
207+
"expression": 'request.time < timestamp("2021-01-01T00:00:00Z")',
210208
}
211209
policy = self._make_one(ETAG, VERSION)
212-
policy.bindings = [{
213-
"role": BIGTABLE_ADMIN_ROLE,
214-
"members": set(members),
215-
"condition": condition
216-
}]
210+
policy.bindings = [
211+
{
212+
"role": BIGTABLE_ADMIN_ROLE,
213+
"members": set(members),
214+
"condition": condition,
215+
}
216+
]
217217
expected = policy_pb2.Policy(
218218
etag=ETAG,
219219
version=VERSION,
220220
bindings=[
221221
policy_pb2.Binding(
222222
role=BIGTABLE_ADMIN_ROLE,
223223
members=sorted(members),
224-
condition=condition)
224+
condition=condition,
225+
)
225226
],
226227
)
227228

0 commit comments

Comments
 (0)