Skip to content

Commit d93afd3

Browse files
committed
Tidy up None-checking of the group identifier.
1 parent 7b424b9 commit d93afd3

File tree

1 file changed

+9
-8
lines changed
  • src/databricks/labs/pytester/fixtures

1 file changed

+9
-8
lines changed

src/databricks/labs/pytester/fixtures/iam.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,26 +116,27 @@ def _wait_group_provisioned(interface: AccountGroupsAPI | GroupsAPI, group: Grou
116116
# interfaces: two subsequent calls need to succeed for us to proceed. (This is probabilistic, and not a guarantee.)
117117
# The REST API internals cache things for up to 60s, and we see times close to this during tests. The retry timeout
118118
# reflects this: if it's taking much longer then something else is wrong.
119+
group_id = group.id
120+
assert group_id is not None
119121

120122
@retried(on=[NotFound], timeout=timedelta(seconds=90))
121-
def _double_get_group(group: Group) -> None:
122-
assert group.id
123-
interface.get(group.id)
124-
interface.get(group.id)
123+
def _double_get_group() -> None:
124+
interface.get(group_id)
125+
interface.get(group_id)
125126

126127
def _check_group_in_listing() -> None:
127-
found_groups = interface.list(attributes="id", filter=f'id eq "{group.id}"')
128+
found_groups = interface.list(attributes="id", filter=f'id eq "{group_id}"')
128129
found_ids = {found_group.id for found_group in found_groups}
129-
if group.id not in found_ids:
130-
msg = f"Group id not (yet) found in group listing: {group.id}"
130+
if group_id not in found_ids:
131+
msg = f"Group id not (yet) found in group listing: {group_id}"
131132
raise NotFound(msg)
132133

133134
@retried(on=[NotFound], timeout=timedelta(seconds=90))
134135
def _double_check_group_in_listing() -> None:
135136
_check_group_in_listing()
136137
_check_group_in_listing()
137138

138-
_double_get_group(group)
139+
_double_get_group()
139140
_double_check_group_in_listing()
140141

141142

0 commit comments

Comments
 (0)