Skip to content

Commit

Permalink
add typing for json_serializer parameter of get_session
Browse files Browse the repository at this point in the history
  • Loading branch information
odrling committed Nov 4, 2024
1 parent 2f6f0aa commit 296ba64
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/mahou/templates/aiohttp_client.py.jinja
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from collections.abc import Sequence
from collections.abc import Callable, Sequence
from dataclasses import dataclass
from datetime import date, datetime, time
from enum import Enum
Expand Down Expand Up @@ -175,13 +175,13 @@ class {{module_name.capitalize()}}Module():
{% endfor %}

class ClientSession(aiohttp.ClientSession):
def __init__(self, server_url: str, *args, **kwargs):
def __init__(self, server_url: str, **kwargs):
super().__init__(*args, **kwargs)
{% for module in modules -%}
self.{{module}}: {{module.capitalize()}}Module = {{module.capitalize()}}Module(self, server_url)
{% endfor %}

{% for server in servers %}
def get{% if server.name %}_{{server.name}}{% endif %}_session(server_url: str, *args, json_serialize=default_json_serializer, **kwargs) -> ClientSession:
return ClientSession(server_url, *args, json_serialize=json_serialize, **kwargs)
def get{% if server.name %}_{{server.name}}{% endif %}_session(server_url: str, *, json_serialize: Callable[[Any], str] = default_json_serializer, **kwargs) -> ClientSession:
return ClientSession(server_url, json_serialize=json_serialize, **kwargs)
{% endfor %}

0 comments on commit 296ba64

Please sign in to comment.