Skip to content

Conversation

@paulo-raca
Copy link
Contributor

@paulo-raca paulo-raca commented Oct 20, 2022

This change is useless on its own 😅

So I'm going to give the context instead:
I'm working on a template with a custom API where the client is provided by self._get_client() instead of an explicit argument, which required a few tweaks to those macros:

@attr.s(auto_attribs=True)
class Endpoints:
    _client: Union[Client, Callable[[], Client]]

    def _get_client(self) -> Client:
        client = self._client
        if callable(client):
            client = client()
        return client

    {% for endpoint in endpoint_collection.endpoints %}
    {% set f_name = python_identifier(endpoint.name) %}
    {% set return_string = endpoint.response_type() %}
    def {{f_name}}_detailed(
        self,
        {{ arguments(endpoint, include_client=False) | indent(4) }}
    ) -> Response[{{ return_string }}]:
        {{ docstring(endpoint, return_string) | indent(4) }}

        from . import {{ f_name }} as _endpoint
        return _endpoint.sync_detailed(
            {{ kwargs(endpoint, include_client = False) }}
            client = self._get_client(),
        )
    {% endfor %}

I'm working on a template where the client is provided by self.get_client() instead of by an explicit argument
@paulo-raca paulo-raca mentioned this pull request Oct 20, 2022
1 task
@dbanty
Copy link
Collaborator

dbanty commented Nov 12, 2022

I don't want to increase the complexity of the existing Jinja code for custom templates—since the usage of custom templates isn't stable. Plus, on the roadmap (somewhere) is changing the way clients work entirely.

@dbanty dbanty closed this Nov 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants