Skip to main content

No project description provided

Project description

Fast Params

Support Rails style QueryParams and FormData for Starlette and FastAPI.

you can also used it in other frameworks, if your params or forms follow this protocol.

@runtime_checkable
class MultiDict(Protocol):
    def multi_items(self) -> list[tuple[str, Any]]: ...

Install

pip install fast-params

Usage

from fast_params import ParamParser
from starlette.datastructures import MultiDict

def test_parse_simple():
    parser = ParamParser()
    params = MultiDict({
        "a": 1,
        "b": 2
    })
    expect = {
        "a": 1,
        "b": 2
    }
    assert parser(params) == expect

def test_array():
    parser = ParamParser()
    params = MultiDict([
        ("a", 1),
        ("b[]", 2),
        ("c[d]", 3),
        ("c[f]", 4),
        ("f[d][]", 5),
        ("f[d][]", 6),
    ])
    expect = {
        "a": 1,
        "b": [2],
        "c": {
            "d": 3,
            "f": 4
        },
        "f": {
            "d": [5, 6]
        }
    }
    assert parser(params) == expect

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fast_params-0.1.1.tar.gz (2.2 kB view hashes)

Uploaded Source

Built Distribution

fast_params-0.1.1-py3-none-any.whl (2.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page