From 37635c2e77fd7a6681309c9546c5faa86c0914a3 Mon Sep 17 00:00:00 2001 From: Charlie Date: Thu, 17 Oct 2024 17:12:07 -0700 Subject: [PATCH] fix: Make str to bool noop if input is bool --- .pre-commit-config.yaml | 2 +- querybook/server/lib/utils/utils.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1a6b0e5a5..08cb9ab7e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: # - '@trivago/prettier-plugin-sort-imports@3.2.0' # removing it since pre-commit install fails - repo: https://github.com/PyCQA/flake8 - rev: 3.9.2 + rev: 7.1.1 hooks: - id: flake8 files: "^querybook/(server|tests)/.*\\.py$" diff --git a/querybook/server/lib/utils/utils.py b/querybook/server/lib/utils/utils.py index 5206c23ca..77bb809c5 100644 --- a/querybook/server/lib/utils/utils.py +++ b/querybook/server/lib/utils/utils.py @@ -162,8 +162,10 @@ def get_default_args(func): } -def str_to_bool(value: Optional[str]) -> bool: +def str_to_bool(value: Optional[str | bool]) -> bool: if value is None: return False + if isinstance(value, bool): + return value return value.lower() in ("yes", "true", "t", "1")