Skip to content

Commit 56d9216

Browse files
committed
Bump version to 0.8.3.3 in pyproject.toml; add orjson dependency; enhance parse_dict_or_list_param function to handle string booleans.
1 parent 35963f4 commit 56d9216

File tree

3 files changed

+182
-16
lines changed

3 files changed

+182
-16
lines changed

pyproject.toml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ keywords = [
2727
name = "FlowerPower"
2828
readme = "README.md"
2929
requires-python = ">= 3.11"
30-
version = "0.8.3.2"
30+
version = "0.8.3.3"
3131

3232
[project.scripts]
3333
flowerpower = "flowerpower.cli:app"
@@ -37,6 +37,7 @@ flowerpower = "flowerpower.cli:app"
3737
filesystem-ext = [
3838
"pyarrow>=18.1.0",
3939
"polars>=1.15.0", #"duckdb>=1.1.3", #"datafusion>=42.0.0",
40+
"orjson>=3.10.12",
4041
]
4142
mongodb = ["pymongo>=4.7.2"]
4243
mqtt = ["paho-mqtt>=2.1.0", "orjson>=3.10.11"]
@@ -71,22 +72,12 @@ requires = ["hatchling"]
7172
dev-dependencies = [
7273
"ipython>=8.24.0",
7374
"isort>=5.13.2",
74-
"pillow>=10.3.0",
75-
"cloudpickle>=3.0.0",
76-
"dill>=0.3.8",
77-
"cbor2>=5.6.4",
78-
"lxml>=5.3.0",
79-
"msgspec>=0.18.6",
8075
"ruff>=0.7.1",
8176
"polars>=1.12.0",
8277
"duckdb>=1.1.3",
83-
"pygit2>=1.16.0",
84-
"s3fs>=2024.10.0",
8578
"jupyterlab>=4.3.0",
8679
"deltalake>=0.21.0",
8780
"datafusion>=42.0.0",
88-
"joblib>=1.4.2",
89-
"toml>=0.10.2",
9081
]
9182
#[tool.rye.scripts]
9283
#flowerpower = {cmd = ["python", "-m", "flowerpower.cli"]}

src/flowerpower/cli/utils.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,26 @@ def parse_dict_or_list_param(
3333
Returns:
3434
dict | list | None: Parsed parameter or None if parsing fails
3535
"""
36+
37+
def convert_string_booleans(obj):
38+
if isinstance(obj, dict):
39+
return {k: convert_string_booleans(v) for k, v in obj.items()}
40+
elif isinstance(obj, list):
41+
return [convert_string_booleans(item) for item in obj]
42+
elif isinstance(obj, str):
43+
if obj.lower() == "true":
44+
return True
45+
elif obj.lower() == "false":
46+
return False
47+
return obj
48+
3649
if value is None:
3750
return None
3851

3952
try:
4053
# Try parsing as JSON first
41-
return json.loads(value)
54+
parsed = json.loads(value)
55+
return convert_string_booleans(parsed)
4256
except json.JSONDecodeError:
4357
try:
4458
# Try parsing as Python literal
@@ -50,13 +64,14 @@ def parse_dict_or_list_param(
5064
elif param_type == "list" and not isinstance(parsed, list):
5165
raise ValueError(f"Expected list, got {type(parsed)}")
5266

53-
return parsed
67+
return convert_string_booleans(parsed)
5468
except (SyntaxError, ValueError):
5569
# For dicts, try parsing as comma-separated key=value pairs
5670
if param_type == "dict" and "=" in value:
57-
return dict(
71+
parsed = dict(
5872
pair.split("=", 1) for pair in value.split(",") if pair.strip()
5973
)
74+
return convert_string_booleans(parsed)
6075

6176
# For lists, try multiple parsing strategies
6277
if param_type == "list":
@@ -70,7 +85,9 @@ def parse_dict_or_list_param(
7085
list_items = re.findall(r"['\"]?(.*?)['\"]?(?=\s*,|\s*$)", value)
7186

7287
# Remove any empty strings and strip whitespace
73-
return [item.strip() for item in list_items if item.strip()]
88+
parsed = [item.strip() for item in list_items if item.strip()]
89+
90+
return convert_string_booleans(parsed)
7491

7592
# If all parsing fails, log warning and return None
7693
logger.warning(f"Could not parse {param_type} parameter: {value}")

0 commit comments

Comments
 (0)