Skip to content

Commit 7757d59

Browse files
committed
Run ruff formater
1 parent b585ad9 commit 7757d59

File tree

6 files changed

+46
-15
lines changed

6 files changed

+46
-15
lines changed

authzed/api/v1/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@
6464
from authzed.api.v1.watch_service_pb2_grpc import WatchServiceStub
6565

6666

67-
class Client(SchemaServiceStub, PermissionsServiceStub, ExperimentalServiceStub, WatchServiceStub):
67+
class Client(
68+
SchemaServiceStub, PermissionsServiceStub, ExperimentalServiceStub, WatchServiceStub
69+
):
6870
"""
6971
v1 Authzed gRPC API client - Auto-detects sync or async depending on if initialized within an event loop
7072
"""

authzed/api/v1/__init__.pyi

+11-3
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,19 @@ from authzed.api.v1.schema_service_pb2 import (
6464
WriteSchemaRequest,
6565
WriteSchemaResponse,
6666
)
67-
from authzed.api.v1.schema_service_pb2_grpc import SchemaServiceAsyncStub, SchemaServiceStub
67+
from authzed.api.v1.schema_service_pb2_grpc import (
68+
SchemaServiceAsyncStub,
69+
SchemaServiceStub,
70+
)
6871
from authzed.api.v1.watch_service_pb2 import WatchRequest, WatchResponse
69-
from authzed.api.v1.watch_service_pb2_grpc import WatchServiceAsyncStub, WatchServiceStub
72+
from authzed.api.v1.watch_service_pb2_grpc import (
73+
WatchServiceAsyncStub,
74+
WatchServiceStub,
75+
)
7076

71-
class Client(SchemaServiceStub, PermissionsServiceStub, ExperimentalServiceStub, WatchServiceStub):
77+
class Client(
78+
SchemaServiceStub, PermissionsServiceStub, ExperimentalServiceStub, WatchServiceStub
79+
):
7280
"""The Client is typed as a synchronous client (though in practice it works with both sync and async code).
7381
If you are using the async code, you should switch to the AsyncClient class instead in order to get proper type hints
7482
"""

examples/v1/bulk_check_permissions.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,11 @@
4747
)
4848
)
4949
assert len(resp.pairs) == 2
50-
assert resp.pairs[0].item.permissionship == CheckPermissionResponse.PERMISSIONSHIP_HAS_PERMISSION
51-
assert resp.pairs[1].item.permissionship == CheckPermissionResponse.PERMISSIONSHIP_HAS_PERMISSION
50+
assert (
51+
resp.pairs[0].item.permissionship
52+
== CheckPermissionResponse.PERMISSIONSHIP_HAS_PERMISSION
53+
)
54+
assert (
55+
resp.pairs[1].item.permissionship
56+
== CheckPermissionResponse.PERMISSIONSHIP_HAS_PERMISSION
57+
)

examples/v1/bulk_import_export_relationships.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
)
6161
]
6262

63-
import_reps = client.BulkImportRelationships(((req for req in reqs)))
63+
import_reps = client.BulkImportRelationships((req for req in reqs))
6464
assert import_reps.num_loaded == 2
6565

6666
export_resp = client.BulkExportRelationships(

examples/v1alpha1/read_schema_async.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
async def async_new_client():
88
# Within an async context, the client's methods are all async:
99
client = Client("grpc.authzed.com:443", bearer_token_credentials("mytoken"))
10-
resp = await client.ReadSchema(ReadSchemaRequest(object_definitions_names=["example/user"]))
10+
resp = await client.ReadSchema(
11+
ReadSchemaRequest(object_definitions_names=["example/user"])
12+
)
1113
print(resp)
1214

1315

tests/v1_test.py

+20-7
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ async def async_client(token) -> AsyncClient:
6161

6262
# The configs array paramaterizes the tests in this file to run with different clients.
6363
# To make changes, modify both the configs array and the config fixture
64-
Config = Literal["Client_autodetect_sync", "Client_autodetect_async", "SyncClient", "AsyncClient"]
64+
Config = Literal[
65+
"Client_autodetect_sync", "Client_autodetect_async", "SyncClient", "AsyncClient"
66+
]
6567
configs: List[Config] = [
6668
"Client_autodetect_sync",
6769
"Client_autodetect_async",
@@ -200,7 +202,10 @@ async def test_caveated_check(client):
200202
context=None,
201203
)
202204
resp = await maybe_await(client.CheckPermission(req))
203-
assert resp.permissionship == CheckPermissionResponse.PERMISSIONSHIP_CONDITIONAL_PERMISSION
205+
assert (
206+
resp.permissionship
207+
== CheckPermissionResponse.PERMISSIONSHIP_CONDITIONAL_PERMISSION
208+
)
204209
assert "likes" in resp.partial_caveat_info.missing_required_context
205210

206211

@@ -272,10 +277,12 @@ async def test_bulk_check(client):
272277

273278
assert len(resp.pairs) == 2
274279
assert (
275-
resp.pairs[0].item.permissionship == CheckPermissionResponse.PERMISSIONSHIP_HAS_PERMISSION
280+
resp.pairs[0].item.permissionship
281+
== CheckPermissionResponse.PERMISSIONSHIP_HAS_PERMISSION
276282
)
277283
assert (
278-
resp.pairs[1].item.permissionship == CheckPermissionResponse.PERMISSIONSHIP_HAS_PERMISSION
284+
resp.pairs[1].item.permissionship
285+
== CheckPermissionResponse.PERMISSIONSHIP_HAS_PERMISSION
279286
)
280287

281288

@@ -308,7 +315,9 @@ async def test_bulk_export_import(client):
308315

309316
# do bulk import
310317
reqs = [BulkImportRelationshipsRequest(relationships=rels)]
311-
import_rels = await maybe_await(empty_client.BulkImportRelationships(((req for req in reqs))))
318+
import_rels = await maybe_await(
319+
empty_client.BulkImportRelationships((req for req in reqs))
320+
)
312321
assert import_rels.num_loaded == 4
313322

314323
# validate all relationships were imported
@@ -381,7 +390,9 @@ async def write_test_tuples(client):
381390
resource=post_one,
382391
relation="caveated_reader",
383392
subject=beatrice,
384-
optional_caveat=ContextualizedCaveat(caveat_name="likes_harry_potter"),
393+
optional_caveat=ContextualizedCaveat(
394+
caveat_name="likes_harry_potter"
395+
),
385396
),
386397
),
387398
]
@@ -420,7 +431,9 @@ async def maybe_await(resp: T) -> T:
420431
return resp
421432

422433

423-
async def maybe_async_iterable_to_list(iterable: Union[Iterable[T], AsyncIterable[T]]) -> List[T]:
434+
async def maybe_async_iterable_to_list(
435+
iterable: Union[Iterable[T], AsyncIterable[T]],
436+
) -> List[T]:
424437
items = []
425438
if isinstance(iterable, AsyncIterable):
426439
async for item in iterable:

0 commit comments

Comments
 (0)