Skip to content

Commit d677c11

Browse files
ImTotemclaude
andcommitted
fix(lint): use getattr for gRPC future resolution
Extract _resolve() helper that uses getattr to avoid pyright reportAttributeAccessIssue on response types that may or may not be futures at runtime. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 82d5876 commit d677c11

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/bcsd_api/authz/client.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ def _update(operation, res_type: str, res_id: str, relation: str, user_id: str)
3939
)
4040

4141

42+
def _resolve(call):
43+
resolve = getattr(call, "result", None)
44+
if resolve:
45+
return resolve()
46+
return call
47+
48+
4249
class AuthzClient:
4350
def __init__(self, endpoint: str, token: str):
4451
self._client = Client(
@@ -54,7 +61,7 @@ def check(self, res_type: str, res_id: str, permission: str, user_id: str) -> bo
5461
subject=_subject_ref(user_id),
5562
)
5663
)
57-
resp = call.result() if hasattr(call, "result") else call
64+
resp = _resolve(call)
5865
return resp.permissionship == _HAS
5966

6067
def add_relation(self, res_type: str, res_id: str, relation: str, user_id: str) -> None:
@@ -64,13 +71,9 @@ def remove_relation(self, res_type: str, res_id: str, relation: str, user_id: st
6471
self._write(_DELETE, res_type, res_id, relation, user_id)
6572

6673
def write_schema(self, schema: str) -> None:
67-
call = self._client.WriteSchema(WriteSchemaRequest(schema=schema))
68-
if hasattr(call, "result"):
69-
call.result()
74+
_resolve(self._client.WriteSchema(WriteSchemaRequest(schema=schema)))
7075

7176
def _write(self, operation: int, res_type: str, res_id: str, relation: str, user_id: str) -> None:
72-
call = self._client.WriteRelationships(
77+
_resolve(self._client.WriteRelationships(
7378
WriteRelationshipsRequest(updates=[_update(operation, res_type, res_id, relation, user_id)])
74-
)
75-
if hasattr(call, "result"):
76-
call.result()
79+
))

0 commit comments

Comments
 (0)