Skip to content

Allow location-based parameters to create/update functions to be Optional #535

Closed as not planned
@johnthagen

Description

@johnthagen

Is your feature request related to a problem? Please describe.

In generated *partial_update.py modules, the type signature is:

def sync(
    id: int,
    *,
    client: AuthenticatedClient,
    form_data: T,
    multipart_data: T,
    json_body: T,
) -> Optional[T]:
    ...

This makes all of the arguments required, and means you have to call it with dummy parameters like:

        t_partial_update.sync(
            my_id,
            client=client,
            json_body=T(),  # Why are these needed if simply set to blank?
            form_data=T(color="RED"),
            multipart_data=T(),  # Why are these needed if simply set to blank?
        )

Describe the solution you'd like

It seems like if the user only wants to provide data for one of the types of request data, such as form_data they should not have to pass the others and the function would look like:

def sync(
    id: int,
    *,
    client: AuthenticatedClient,
    form_data: Optional[T] = None,
    multipart_data: Optional[T] = None,
    json_body: Optional[T] = None,
) -> Optional[T]:
    ...

And could call it like:

        t_partial_update.sync(
            my_id,
            client=client,
            form_data=T(color="RED"),
        )

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions