Skip to content

Commit 9c85094

Browse files
evansimsEvan Sims
authored andcommitted
feat: type hinting improvements
1 parent 24d73b5 commit 9c85094

File tree

151 files changed

+2008
-1522
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+2008
-1522
lines changed

.openapi-generator/FILES

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ openfga_sdk/telemetry/counters.py
258258
openfga_sdk/telemetry/histograms.py
259259
openfga_sdk/telemetry/metrics.py
260260
openfga_sdk/telemetry/telemetry.py
261-
openfga_sdk/telemetry/utilities.py
262261
openfga_sdk/validation.py
263262
pyproject.toml
264263
requirements.txt
@@ -285,5 +284,4 @@ test/telemetry/counters_test.py
285284
test/telemetry/histograms_test.py
286285
test/telemetry/metrics_test.py
287286
test/telemetry/telemetry_test.py
288-
test/telemetry/utilities_test.py
289287
test/test_open_fga_api.py

example/example1/example1.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
from dotenv import load_dotenv
2121

22+
2223
sdk_path = os.path.realpath(os.path.join(os.path.abspath(__file__), "..", "..", ".."))
2324
sys.path.insert(0, sdk_path)
2425

example/example1/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ python-dateutil >= 2.8.2
99
urllib3 >= 2.1.0
1010
yarl >= 1.9.4
1111
python-dotenv >= 1, <2
12+

example/example1/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from setuptools import find_packages, setup
1414

15+
1516
NAME = "example1"
1617
VERSION = "0.0.1"
1718
REQUIRES = ["openfga-sdk >= 0.9.1"]

example/opentelemetry/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import asyncio
1616
import os
1717
import sys
18+
1819
from operator import attrgetter
1920
from random import randint
2021
from typing import Any
@@ -29,6 +30,7 @@
2930
)
3031
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
3132

33+
3234
# For usage convenience of this example, we will import the OpenFGA SDK from the parent directory.
3335
sdk_path = os.path.realpath(os.path.join(os.path.abspath(__file__), "..", "..", ".."))
3436
sys.path.insert(0, sdk_path)

example/opentelemetry/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from setuptools import find_packages, setup
1414

15+
1516
NAME = "openfga-opentelemetry-example"
1617
VERSION = "0.0.1"
1718
REQUIRES = [""]

example/streamed-list-objects/asynchronous.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
import json
1717
import os
1818
import sys
19+
1920
from operator import attrgetter
2021
from typing import Any
2122

2223
from dotenv import load_dotenv
2324

25+
2426
sdk_path = os.path.realpath(os.path.join(os.path.abspath(__file__), "..", "..", ".."))
2527
sys.path.insert(0, sdk_path)
2628

example/streamed-list-objects/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from setuptools import find_packages, setup
1414

15+
1516
NAME = "openfga-streamed-list-objects-example"
1617
VERSION = "0.0.1"
1718
REQUIRES = [""]

example/streamed-list-objects/synchronous.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
import json
1616
import os
1717
import sys
18+
1819
from operator import attrgetter
1920
from typing import Any
2021

2122
from dotenv import load_dotenv
2223

24+
2325
sdk_path = os.path.realpath(os.path.join(os.path.abspath(__file__), "..", "..", ".."))
2426
sys.path.insert(0, sdk_path)
2527

openfga_sdk/__init__.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,19 @@
1212

1313
__version__ = "0.9.1"
1414

15-
from openfga_sdk.client.client import OpenFgaClient
16-
from openfga_sdk.client.configuration import ClientConfiguration
17-
1815
from openfga_sdk.api.open_fga_api import OpenFgaApi
19-
2016
from openfga_sdk.api_client import ApiClient
17+
from openfga_sdk.client.client import OpenFgaClient
18+
from openfga_sdk.client.configuration import ClientConfiguration
2119
from openfga_sdk.configuration import Configuration
22-
23-
from openfga_sdk.exceptions import OpenApiException
24-
from openfga_sdk.exceptions import FgaValidationException
25-
from openfga_sdk.exceptions import ApiValueError
26-
from openfga_sdk.exceptions import ApiKeyError
27-
from openfga_sdk.exceptions import ApiAttributeError
28-
from openfga_sdk.exceptions import ApiException
29-
20+
from openfga_sdk.exceptions import (
21+
ApiAttributeError,
22+
ApiException,
23+
ApiKeyError,
24+
ApiValueError,
25+
FgaValidationException,
26+
OpenApiException,
27+
)
3028
from openfga_sdk.models.aborted_message_response import AbortedMessageResponse
3129
from openfga_sdk.models.any import Any
3230
from openfga_sdk.models.assertion import Assertion
@@ -137,7 +135,6 @@
137135
from openfga_sdk.models.write_request import WriteRequest
138136
from openfga_sdk.models.write_request_deletes import WriteRequestDeletes
139137
from openfga_sdk.models.write_request_writes import WriteRequestWrites
140-
141138
from openfga_sdk.telemetry.configuration import (
142139
TelemetryConfiguration,
143140
TelemetryConfigurations,
@@ -146,6 +143,7 @@
146143
TelemetryMetricsConfiguration,
147144
)
148145

146+
149147
__all__ = [
150148
"OpenFgaClient",
151149
"ClientConfiguration",

openfga_sdk/api/open_fga_api.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ async def batch_check_with_http_info(self, body, **kwargs):
194194
500: "InternalErrorMessageResponse",
195195
}
196196

197-
telemetry_attributes: dict[TelemetryAttribute, str | int] = {
197+
telemetry_attributes: dict[TelemetryAttribute, str | bool | int | float] = {
198198
TelemetryAttributes.fga_client_request_method: "batch_check",
199199
TelemetryAttributes.fga_client_request_store_id: self.api_client.get_store_id(),
200200
TelemetryAttributes.fga_client_request_model_id: local_var_params.get(
@@ -375,7 +375,7 @@ async def check_with_http_info(self, body, **kwargs):
375375
500: "InternalErrorMessageResponse",
376376
}
377377

378-
telemetry_attributes: dict[TelemetryAttribute, str | int] = {
378+
telemetry_attributes: dict[TelemetryAttribute, str | bool | int | float] = {
379379
TelemetryAttributes.fga_client_request_method: "check",
380380
TelemetryAttributes.fga_client_request_store_id: self.api_client.get_store_id(),
381381
TelemetryAttributes.fga_client_request_model_id: local_var_params.get(
@@ -543,7 +543,7 @@ async def create_store_with_http_info(self, body, **kwargs):
543543
500: "InternalErrorMessageResponse",
544544
}
545545

546-
telemetry_attributes: dict[TelemetryAttribute, str | int] = {
546+
telemetry_attributes: dict[TelemetryAttribute, str | bool | int | float] = {
547547
TelemetryAttributes.fga_client_request_method: "create_store",
548548
TelemetryAttributes.fga_client_request_store_id: self.api_client.get_store_id(),
549549
TelemetryAttributes.fga_client_request_model_id: local_var_params.get(
@@ -692,7 +692,7 @@ async def delete_store_with_http_info(self, **kwargs):
692692

693693
response_types_map = {}
694694

695-
telemetry_attributes: dict[TelemetryAttribute, str | int] = {
695+
telemetry_attributes: dict[TelemetryAttribute, str | bool | int | float] = {
696696
TelemetryAttributes.fga_client_request_method: "delete_store",
697697
TelemetryAttributes.fga_client_request_store_id: self.api_client.get_store_id(),
698698
TelemetryAttributes.fga_client_request_model_id: local_var_params.get(
@@ -873,7 +873,7 @@ async def expand_with_http_info(self, body, **kwargs):
873873
500: "InternalErrorMessageResponse",
874874
}
875875

876-
telemetry_attributes: dict[TelemetryAttribute, str | int] = {
876+
telemetry_attributes: dict[TelemetryAttribute, str | bool | int | float] = {
877877
TelemetryAttributes.fga_client_request_method: "expand",
878878
TelemetryAttributes.fga_client_request_store_id: self.api_client.get_store_id(),
879879
TelemetryAttributes.fga_client_request_model_id: local_var_params.get(
@@ -1030,7 +1030,7 @@ async def get_store_with_http_info(self, **kwargs):
10301030
500: "InternalErrorMessageResponse",
10311031
}
10321032

1033-
telemetry_attributes: dict[TelemetryAttribute, str | int] = {
1033+
telemetry_attributes: dict[TelemetryAttribute, str | bool | int | float] = {
10341034
TelemetryAttributes.fga_client_request_method: "get_store",
10351035
TelemetryAttributes.fga_client_request_store_id: self.api_client.get_store_id(),
10361036
TelemetryAttributes.fga_client_request_model_id: local_var_params.get(
@@ -1212,7 +1212,7 @@ async def list_objects_with_http_info(self, body, **kwargs):
12121212
500: "InternalErrorMessageResponse",
12131213
}
12141214

1215-
telemetry_attributes: dict[TelemetryAttribute, str | int] = {
1215+
telemetry_attributes: dict[TelemetryAttribute, str | bool | int | float] = {
12161216
TelemetryAttributes.fga_client_request_method: "list_objects",
12171217
TelemetryAttributes.fga_client_request_store_id: self.api_client.get_store_id(),
12181218
TelemetryAttributes.fga_client_request_model_id: local_var_params.get(
@@ -1378,7 +1378,7 @@ async def list_stores_with_http_info(self, **kwargs):
13781378
500: "InternalErrorMessageResponse",
13791379
}
13801380

1381-
telemetry_attributes: dict[TelemetryAttribute, str | int] = {
1381+
telemetry_attributes: dict[TelemetryAttribute, str | bool | int | float] = {
13821382
TelemetryAttributes.fga_client_request_method: "list_stores",
13831383
TelemetryAttributes.fga_client_request_store_id: self.api_client.get_store_id(),
13841384
TelemetryAttributes.fga_client_request_model_id: local_var_params.get(
@@ -1559,7 +1559,7 @@ async def list_users_with_http_info(self, body, **kwargs):
15591559
500: "InternalErrorMessageResponse",
15601560
}
15611561

1562-
telemetry_attributes: dict[TelemetryAttribute, str | int] = {
1562+
telemetry_attributes: dict[TelemetryAttribute, str | bool | int | float] = {
15631563
TelemetryAttributes.fga_client_request_method: "list_users",
15641564
TelemetryAttributes.fga_client_request_store_id: self.api_client.get_store_id(),
15651565
TelemetryAttributes.fga_client_request_model_id: local_var_params.get(
@@ -1740,7 +1740,7 @@ async def read_with_http_info(self, body, **kwargs):
17401740
500: "InternalErrorMessageResponse",
17411741
}
17421742

1743-
telemetry_attributes: dict[TelemetryAttribute, str | int] = {
1743+
telemetry_attributes: dict[TelemetryAttribute, str | bool | int | float] = {
17441744
TelemetryAttributes.fga_client_request_method: "read",
17451745
TelemetryAttributes.fga_client_request_store_id: self.api_client.get_store_id(),
17461746
TelemetryAttributes.fga_client_request_model_id: local_var_params.get(
@@ -1917,7 +1917,7 @@ async def read_assertions_with_http_info(self, authorization_model_id, **kwargs)
19171917
500: "InternalErrorMessageResponse",
19181918
}
19191919

1920-
telemetry_attributes: dict[TelemetryAttribute, str | int] = {
1920+
telemetry_attributes: dict[TelemetryAttribute, str | bool | int | float] = {
19211921
TelemetryAttributes.fga_client_request_method: "read_assertions",
19221922
TelemetryAttributes.fga_client_request_store_id: self.api_client.get_store_id(),
19231923
TelemetryAttributes.fga_client_request_model_id: local_var_params.get(
@@ -2092,7 +2092,7 @@ async def read_authorization_model_with_http_info(self, id, **kwargs):
20922092
500: "InternalErrorMessageResponse",
20932093
}
20942094

2095-
telemetry_attributes: dict[TelemetryAttribute, str | int] = {
2095+
telemetry_attributes: dict[TelemetryAttribute, str | bool | int | float] = {
20962096
TelemetryAttributes.fga_client_request_method: "read_authorization_model",
20972097
TelemetryAttributes.fga_client_request_store_id: self.api_client.get_store_id(),
20982098
TelemetryAttributes.fga_client_request_model_id: local_var_params.get(
@@ -2266,7 +2266,7 @@ async def read_authorization_models_with_http_info(self, **kwargs):
22662266
500: "InternalErrorMessageResponse",
22672267
}
22682268

2269-
telemetry_attributes: dict[TelemetryAttribute, str | int] = {
2269+
telemetry_attributes: dict[TelemetryAttribute, str | bool | int | float] = {
22702270
TelemetryAttributes.fga_client_request_method: "read_authorization_models",
22712271
TelemetryAttributes.fga_client_request_store_id: self.api_client.get_store_id(),
22722272
TelemetryAttributes.fga_client_request_model_id: local_var_params.get(
@@ -2450,7 +2450,7 @@ async def read_changes_with_http_info(self, **kwargs):
24502450
500: "InternalErrorMessageResponse",
24512451
}
24522452

2453-
telemetry_attributes: dict[TelemetryAttribute, str | int] = {
2453+
telemetry_attributes: dict[TelemetryAttribute, str | bool | int | float] = {
24542454
TelemetryAttributes.fga_client_request_method: "read_changes",
24552455
TelemetryAttributes.fga_client_request_store_id: self.api_client.get_store_id(),
24562456
TelemetryAttributes.fga_client_request_model_id: local_var_params.get(
@@ -2632,7 +2632,7 @@ async def streamed_list_objects_with_http_info(self, body, **kwargs):
26322632
500: "InternalErrorMessageResponse",
26332633
}
26342634

2635-
telemetry_attributes: dict[TelemetryAttribute, str | int] = {
2635+
telemetry_attributes: dict[TelemetryAttribute, str | bool | int | float] = {
26362636
TelemetryAttributes.fga_client_request_method: "streamed_list_objects",
26372637
TelemetryAttributes.fga_client_request_store_id: self.api_client.get_store_id(),
26382638
TelemetryAttributes.fga_client_request_model_id: local_var_params.get(
@@ -2813,7 +2813,7 @@ async def write_with_http_info(self, body, **kwargs):
28132813
500: "InternalErrorMessageResponse",
28142814
}
28152815

2816-
telemetry_attributes: dict[TelemetryAttribute, str | int] = {
2816+
telemetry_attributes: dict[TelemetryAttribute, str | bool | int | float] = {
28172817
TelemetryAttributes.fga_client_request_method: "write",
28182818
TelemetryAttributes.fga_client_request_store_id: self.api_client.get_store_id(),
28192819
TelemetryAttributes.fga_client_request_model_id: local_var_params.get(
@@ -3007,7 +3007,7 @@ async def write_assertions_with_http_info(
30073007

30083008
response_types_map = {}
30093009

3010-
telemetry_attributes: dict[TelemetryAttribute, str | int] = {
3010+
telemetry_attributes: dict[TelemetryAttribute, str | bool | int | float] = {
30113011
TelemetryAttributes.fga_client_request_method: "write_assertions",
30123012
TelemetryAttributes.fga_client_request_store_id: self.api_client.get_store_id(),
30133013
TelemetryAttributes.fga_client_request_model_id: local_var_params.get(
@@ -3191,7 +3191,7 @@ async def write_authorization_model_with_http_info(self, body, **kwargs):
31913191
500: "InternalErrorMessageResponse",
31923192
}
31933193

3194-
telemetry_attributes: dict[TelemetryAttribute, str | int] = {
3194+
telemetry_attributes: dict[TelemetryAttribute, str | bool | int | float] = {
31953195
TelemetryAttributes.fga_client_request_method: "write_authorization_model",
31963196
TelemetryAttributes.fga_client_request_store_id: self.api_client.get_store_id(),
31973197
TelemetryAttributes.fga_client_request_model_id: local_var_params.get(

openfga_sdk/api_client.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@
1919
import re
2020
import time
2121
import urllib
22+
2223
from multiprocessing.pool import ThreadPool
2324

24-
from dateutil.parser import parse
25+
from dateutil.parser import parse # type: ignore[import-untyped]
2526

2627
import openfga_sdk.models
27-
from openfga_sdk import rest, oauth2
28+
29+
from openfga_sdk import oauth2, rest
2830
from openfga_sdk.configuration import Configuration
2931
from openfga_sdk.exceptions import (
3032
ApiException,
@@ -36,6 +38,7 @@
3638
from openfga_sdk.telemetry import Telemetry
3739
from openfga_sdk.telemetry.attributes import TelemetryAttribute, TelemetryAttributes
3840

41+
3942
DEFAULT_USER_AGENT = "openfga-sdk python/0.9.1"
4043

4144

@@ -166,7 +169,8 @@ async def __call_api(
166169
_request_auth=None,
167170
_retry_params=None,
168171
_oauth2_client=None,
169-
_telemetry_attributes: dict[TelemetryAttribute, str | int] = None,
172+
_telemetry_attributes: dict[TelemetryAttribute, str | bool | int | float]
173+
| None = None,
170174
_streaming: bool = False,
171175
):
172176
self.configuration.is_valid()
@@ -511,7 +515,8 @@ async def call_api(
511515
_request_auth=None,
512516
_retry_params=None,
513517
_oauth2_client=None,
514-
_telemetry_attributes: dict[TelemetryAttribute, str | int] = None,
518+
_telemetry_attributes: dict[TelemetryAttribute, str | bool | int | float]
519+
| None = None,
515520
_streaming: bool = False,
516521
):
517522
"""Makes the HTTP request (synchronous) and returns deserialized data.

openfga_sdk/client/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from openfga_sdk.client.configuration import ClientConfiguration
1515
from openfga_sdk.client.models.check_request import ClientCheckRequest
1616

17+
1718
__all__ = [
1819
"OpenFgaClient",
1920
"ClientConfiguration",

0 commit comments

Comments
 (0)