Skip to content

Commit a28534c

Browse files
committed
correct type hinting in synapseclient.api.json_schema_service.py
1 parent f0f6844 commit a28534c

File tree

1 file changed

+70
-28
lines changed

1 file changed

+70
-28
lines changed

synapseclient/api/json_schema_services.py

Lines changed: 70 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import json
2-
from typing import TYPE_CHECKING, AsyncGenerator, Optional
2+
from typing import (
3+
TYPE_CHECKING,
4+
Any,
5+
AsyncGenerator,
6+
Dict,
7+
Generator,
8+
List,
9+
Optional,
10+
Union,
11+
)
312

413
from synapseclient.api.api_client import rest_post_paginated_async
514

615
if TYPE_CHECKING:
716
from synapseclient import Synapse
8-
from synapseclient.models.mixins import (
9-
InvalidJSONSchemaValidation,
10-
JSONSchemaBinding,
11-
JSONSchemaDerivedKeys,
12-
JSONSchemaValidation,
13-
JSONSchemaValidationStatistics,
14-
)
1517

1618

1719
async def bind_json_schema_to_entity(
@@ -20,8 +22,11 @@ async def bind_json_schema_to_entity(
2022
*,
2123
enable_derived_annos: bool = False,
2224
synapse_client: Optional["Synapse"] = None,
23-
) -> "JSONSchemaBinding":
24-
"""Bind a JSON schema to an entity
25+
) -> Union[Dict[str, Any], str]:
26+
"""
27+
<https://rest-docs.synapse.org/rest/PUT/entity/id/schema/binding.html>
28+
29+
Bind a JSON schema to an entity
2530
2631
Arguments:
2732
synapse_id: Synapse Entity or Synapse Id
@@ -31,7 +36,7 @@ async def bind_json_schema_to_entity(
3136
`Synapse.allow_client_caching(False)` this will use the last created
3237
instance from the Synapse class constructor
3338
Returns:
34-
A JSONSchemaBindingResponse object containing the details of the binding.
39+
Object matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/schema/JsonSchemaObjectBinding.html>
3540
"""
3641
from synapseclient import Synapse
3742

@@ -48,8 +53,11 @@ async def bind_json_schema_to_entity(
4853

4954
async def get_json_schema_from_entity(
5055
synapse_id: str, *, synapse_client: Optional["Synapse"] = None
51-
) -> "JSONSchemaBinding":
52-
"""Get bound schema from entity
56+
) -> Union[Dict[str, Any], str]:
57+
"""
58+
<https://rest-docs.synapse.org/rest/GET/entity/id/schema/binding.html>
59+
60+
Get bound schema from entity
5361
5462
Arguments:
5563
synapse_id: Synapse Id
@@ -58,7 +66,7 @@ async def get_json_schema_from_entity(
5866
instance from the Synapse class constructor
5967
6068
Returns:
61-
A JSONSchemaBindingResponse object containing the details of the binding.
69+
Object matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/schema/JsonSchemaObjectBinding.html>
6270
"""
6371
from synapseclient import Synapse
6472

@@ -69,7 +77,11 @@ async def get_json_schema_from_entity(
6977
async def delete_json_schema_from_entity(
7078
synapse_id: str, *, synapse_client: Optional["Synapse"] = None
7179
) -> None:
72-
"""Delete bound schema from entity
80+
"""
81+
<https://rest-docs.synapse.org/rest/DELETE/entity/id/schema/binding.html>
82+
83+
Delete bound schema from entity
84+
7385
Arguments:
7486
synapse_id: Synapse Id
7587
synapse_client: If not passed in and caching was not disabled by
@@ -84,16 +96,19 @@ async def delete_json_schema_from_entity(
8496

8597
async def validate_entity_with_json_schema(
8698
synapse_id: str, *, synapse_client: Optional["Synapse"] = None
87-
) -> "JSONSchemaValidation":
88-
"""Get validation results of an entity against bound JSON schema
99+
) -> Union[Dict[str, Union[str, bool]], str]:
100+
"""
101+
<https://rest-docs.synapse.org/rest/GET/entity/id/schema/validation.html>
102+
103+
Get validation results of an entity against bound JSON schema
89104
90105
Arguments:
91106
synapse_id: Synapse Id
92107
synapse_client: If not passed in and caching was not disabled by
93108
`Synapse.allow_client_caching(False)` this will use the last created
94109
instance from the Synapse class constructor
95110
Returns:
96-
A JSONSchemaValidationResponse object containing the validation results.
111+
Object matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/schema/ValidationResults.html>
97112
"""
98113
from synapseclient import Synapse
99114

@@ -103,16 +118,21 @@ async def validate_entity_with_json_schema(
103118

104119
async def get_json_schema_validation_statistics(
105120
synapse_id: str, *, synapse_client: Optional["Synapse"] = None
106-
) -> "JSONSchemaValidationStatistics":
107-
"""Get the summary statistic of json schema validation results for
121+
) -> Dict[str, Union[str, int]]:
122+
"""
123+
124+
<https://rest-docs.synapse.org/rest/GET/entity/id/schema/validation/statistics.html>
125+
126+
Get the summary statistic of json schema validation results for
108127
a container entity
109128
Arguments:
110129
synapse_id: Synapse Id
111130
synapse_client: If not passed in and caching was not disabled by
112131
`Synapse.allow_client_caching(False)` this will use the last created
113132
instance from the Synapse class constructor
114133
115-
Returns: a JSONSchemaValidationStatisticsResponse object
134+
Returns:
135+
Object matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/schema/ValidationSummaryStatistics.html>
116136
"""
117137
from synapseclient import Synapse
118138

@@ -124,8 +144,12 @@ async def get_json_schema_validation_statistics(
124144

125145
async def get_invalid_json_schema_validation(
126146
synapse_id: str, *, synapse_client: Optional["Synapse"] = None
127-
) -> AsyncGenerator["InvalidJSONSchemaValidation", None]:
128-
"""Get a single page of invalid JSON schema validation results for a container Entity
147+
) -> AsyncGenerator[Dict[str, Any], None]:
148+
"""
149+
150+
<https://rest-docs.synapse.org/rest/POST/entity/id/schema/validation/invalid.html>
151+
152+
Get a single page of invalid JSON schema validation results for a container Entity
129153
(Project or Folder).
130154
131155
Arguments:
@@ -134,7 +158,7 @@ async def get_invalid_json_schema_validation(
134158
`Synapse.allow_client_caching(False)` this will use the last created
135159
instance from the Synapse class constructor
136160
Returns:
137-
An AsyncGenerator yielding InvalidJSONSchemaValidationResponse objects.
161+
Object matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/schema/ValidationResults.html>
138162
"""
139163

140164
request_body = {"containerId": synapse_id}
@@ -149,7 +173,22 @@ async def get_invalid_json_schema_validation(
149173

150174
def get_invalid_json_schema_validation_sync(
151175
synapse_id: str, *, synapse_client: Optional["Synapse"] = None
152-
):
176+
) -> Generator[Dict[str, Any], None]:
177+
"""
178+
179+
<https://rest-docs.synapse.org/rest/POST/entity/id/schema/validation/invalid.html>
180+
181+
Get a single page of invalid JSON schema validation results for a container Entity
182+
(Project or Folder).
183+
184+
Arguments:
185+
synapse_id: Synapse Id
186+
synapse_client: If not passed in and caching was not disabled by
187+
`Synapse.allow_client_caching(False)` this will use the last created
188+
instance from the Synapse class constructor
189+
Returns:
190+
Object matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/schema/ValidationResults.html>
191+
"""
153192
request_body = {"containerId": synapse_id}
154193
response = synapse_client._POST_paginated(
155194
f"/entity/{synapse_id}/schema/validation/invalid", request_body
@@ -160,14 +199,17 @@ def get_invalid_json_schema_validation_sync(
160199

161200
async def get_json_schema_derived_keys(
162201
synapse_id: str, *, synapse_client: Optional["Synapse"] = None
163-
) -> "JSONSchemaDerivedKeys":
164-
"""Retrieve derived JSON schema keys for a given Synapse entity.
202+
) -> List[str]:
203+
"""
204+
<https://rest-docs.synapse.org/rest/GET/entity/id/derivedKeys.html>
205+
206+
Retrieve derived JSON schema keys for a given Synapse entity.
165207
166208
Arguments:
167209
synapse_id (str): The Synapse ID of the entity for which to retrieve derived keys.
168210
169211
Returns:
170-
dict: JSONSchemaDerivedKeysResponse object containing the derived keys for the entity.
212+
Object matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/annotation/v2/Keys.html>
171213
"""
172214
from synapseclient import Synapse
173215

0 commit comments

Comments
 (0)