Skip to content

Convert request params based on function annotations. #1441

@coady

Description

@coady

With the increasing focus on type hints in Python, having a tool which automatically converted query params (with exception handling) would be a nice feature.

It's common for apps to have boilerplate code for converting request params, and returning 400-levels errors on failure.

@cherrypy.tools.params(exception=ValueError)
def resource(self, limit: int):
    assert isinstance(limit, int) # a ValueError would have already raised a 400

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions