Skip to content

bug(*): fix Boolean query params #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2021
Merged

bug(*): fix Boolean query params #128

merged 1 commit into from
Dec 14, 2021

Conversation

zbjornson
Copy link
Member

Affects plots and anything else where CellEngine's API is case-sensitive (might only be plots). We'll make the API case-insensitive at some point soon as well.

Fixes #124

Affects plots and anything else where CellEngine's API is case-sensitive (might only be plots). We'll make the API case-insensitive at some point soon as well.

Fixes #124
@gegnew
Copy link
Contributor

gegnew commented Dec 14, 2021

lgtm 🌞

@gegnew
Copy link
Contributor

gegnew commented Dec 14, 2021

I guess if you wanted to be tricky I guess you could make prepare_params a decorator, which would make the implementation look like:

@prepare_params
def _get():
    # ...
    # instead of:
    # params=prepare_params(params if params else {}),

which would look like:

from functools import wraps

def prepare_params(f):
    @wraps(f)
    def wrapped(*args, **kwargs):
        if "params" in kwargs:
            kwargs["params"] = {k: str(v).lower() if type(v) == bool else v for k, v in kwargs["params"].items()}
        return f(*args, **kwargs)
    return wrapped

@zbjornson
Copy link
Member Author

I like simple ;).

@zbjornson zbjornson merged commit a306cc0 into master Dec 14, 2021
@zbjornson zbjornson deleted the zb/124 branch December 14, 2021 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plot.get / renderGates requires renderGates to be a string instead of bool
2 participants