Skip to content

Conversation

@castroofelipee
Copy link
Member

What?

This PR extends the _cast function’s list handling to support JSON-formatted strings in addition to simple comma-separated strings. Closes #5

Before
_cast('["a", "b", "c"]', list)
# Returned: ['["a"', '"b"', '"c"]']
After
_cast('["a", "b", "c"]', list)
# Returned: ['["a"', '"b"', '"c"]']

Why

Environment variables may be supplied as valid JSON arrays (especially in containerized environments or .env files).
Previously, _cast only supported comma-separated lists, which caused incorrect parsing for JSON-style inputs.

Tests

Updated test suite to include test_cast_list_json_valid for JSON lists.

- Allow _cast to parse list values from JSON strings in addition to comma-separated values.
- This enables environment variables like '["a", "b", "c"]' to be parsed correctly into Python lists.
@castroofelipee castroofelipee self-assigned this Aug 12, 2025
@castroofelipee castroofelipee linked an issue Aug 12, 2025 that may be closed by this pull request
@castroofelipee castroofelipee merged commit 1540cd9 into master Aug 12, 2025
2 checks passed
@castroofelipee castroofelipee deleted the 5-improve-type-casting branch August 12, 2025 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve Type Casting

2 participants