Skip to content

fix(python): update deserialization templates and typing issues #3780

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

Merged
merged 17 commits into from
Sep 24, 2024
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
23 changes: 4 additions & 19 deletions playground/python/app/search.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
from asyncio import run
from os import environ
from base64 import b64decode

from algoliasearch.search.client import SearchClient
from algoliasearch.search.models.search_params_object import SearchParamsObject
from algoliasearch.search.models.secured_api_key_restrictions import (
SecuredApiKeyRestrictions,
)
from algoliasearch.search import __version__
from dotenv import load_dotenv

Expand All @@ -22,20 +17,10 @@ async def main():
print("client initialized", client)

try:
# resp = await client.search(search_method_params={
# "requests": [{"indexName": "api-clients-automation"}]
# })
# print(resp.to_dict())
print(
b64decode(await client.generate_secured_api_key(
"foo",
SecuredApiKeyRestrictions(
restrictIndices=["foo"],
filters="bar",
searchParams=SearchParamsObject(attributesToRetrieve=["baz"]),
),
))
)
resp = await client.search(search_method_params={
"requests": [{"indexName": "api-clients-automation"}]
})
print(resp.to_dict())
finally:
await client.close()

Expand Down
8 changes: 5 additions & 3 deletions templates/python/imports.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@ from typing import (
Dict,
Iterator,
List,
Literal,
Set,
Optional,
Tuple,
Union,
)

from typing_extensions import Annotated

if version_info >= (3, 11):
from typing import Self, Annotated
from typing import Self
else:
from typing_extensions import Self, Annotated
from typing_extensions import Self

from algoliasearch.http.helpers import create_iterable, create_iterable_sync, RetryTimeout
from algoliasearch.http.serializer import bodySerializer, QueryParametersSerializer
Expand Down
3 changes: 2 additions & 1 deletion templates/python/model_enum.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class {{classname}}({{vendorExtensions.x-py-enum-type}}, Enum):
{{#allowableValues}}
{{#enumVars}}
{{{name}}} = {{{value}}}

{{/enumVars}}

@classmethod
Expand All @@ -22,4 +23,4 @@ class {{classname}}({{vendorExtensions.x-py-enum-type}}, Enum):
if value is no_arg:
return cls.{{{.}}}
{{/defaultValue}}
{{/allowableValues}}
{{/allowableValues}}
Loading
Loading