Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: type hinting improvements #167

Merged
merged 2 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ openfga_sdk/telemetry/counters.py
openfga_sdk/telemetry/histograms.py
openfga_sdk/telemetry/metrics.py
openfga_sdk/telemetry/telemetry.py
openfga_sdk/telemetry/utilities.py
openfga_sdk/validation.py
pyproject.toml
requirements.txt
Expand All @@ -285,5 +284,4 @@ test/telemetry/counters_test.py
test/telemetry/histograms_test.py
test/telemetry/metrics_test.py
test/telemetry/telemetry_test.py
test/telemetry/utilities_test.py
test/test_open_fga_api.py
1 change: 1 addition & 0 deletions example/example1/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ python-dateutil >= 2.8.2
urllib3 >= 2.1.0
yarl >= 1.9.4
python-dotenv >= 1, <2

84 changes: 36 additions & 48 deletions openfga_sdk/api/open_fga_api.py

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions openfga_sdk/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from multiprocessing.pool import ThreadPool

from dateutil.parser import parse
from dateutil.parser import parse # type: ignore[import-untyped]

import openfga_sdk.models

Expand Down Expand Up @@ -169,7 +169,8 @@ async def __call_api(
_request_auth=None,
_retry_params=None,
_oauth2_client=None,
_telemetry_attributes: dict[TelemetryAttribute, str | int] = None,
_telemetry_attributes: dict[TelemetryAttribute, str | bool | int | float]
| None = None,
_streaming: bool = False,
):
self.configuration.is_valid()
Expand All @@ -193,10 +194,9 @@ async def __call_api(
path_params = self.parameters_to_tuples(path_params, collection_formats)
for k, v in path_params:
# specified safe chars, encode everything
resource_path = resource_path.replace(
"{%s}" % k,
urllib.parse.quote(str(v), safe=config.safe_chars_for_path_param),
)
_k = urllib.parse.quote(str(k), safe=config.safe_chars_for_path_param)
_v = urllib.parse.quote(str(v), safe=config.safe_chars_for_path_param)
resource_path = resource_path.replace("{" + str(k) + "}", _v)

# query parameters
if query_params:
Expand Down Expand Up @@ -414,7 +414,7 @@ def sanitize_for_serialization(self, obj):
return [self.sanitize_for_serialization(sub_obj) for sub_obj in obj]
elif isinstance(obj, tuple):
return tuple(self.sanitize_for_serialization(sub_obj) for sub_obj in obj)
elif isinstance(obj, (datetime.datetime, datetime.date)):
elif isinstance(obj, datetime.datetime | datetime.date):
return obj.isoformat()

if isinstance(obj, dict):
Expand Down Expand Up @@ -514,7 +514,8 @@ async def call_api(
_request_auth=None,
_retry_params=None,
_oauth2_client=None,
_telemetry_attributes: dict[TelemetryAttribute, str | int] = None,
_telemetry_attributes: dict[TelemetryAttribute, str | bool | int | float]
| None = None,
_streaming: bool = False,
):
"""Makes the HTTP request (synchronous) and returns deserialized data.
Expand Down Expand Up @@ -848,7 +849,7 @@ def __deserialize_model(self, data, klass):
if (
data is not None
and klass.openapi_types is not None
and isinstance(data, (list, dict))
and isinstance(data, list | dict)
):
for attr, attr_type in klass.openapi_types.items():
if klass.attribute_map[attr] in data:
Expand Down
Loading