Skip to content

Commit

Permalink
fix: handle config being provided as list
Browse files Browse the repository at this point in the history
  • Loading branch information
joaodaher committed Jul 2, 2024
1 parent 733232a commit 022f343
Show file tree
Hide file tree
Showing 3 changed files with 432 additions and 456 deletions.
12 changes: 11 additions & 1 deletion django_cloud_tasks/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,17 @@ def _fetch_float_config(self, name: str, default: Any) -> float:

def _fetch_list_config(self, name: str, default: Any) -> list:
value = self._fetch_config(name=name, default=default)
return value.split(",") if value is not None and isinstance(value, str) else default

if not value:
return default

if isinstance(value, list):
return value

if isinstance(value, str):
return value.split(",")

raise ValueError(f"Invalid value for {name}: {value}")

def register_task(self, task_class):
from django_cloud_tasks.tasks.periodic_task import PeriodicTask
Expand Down
Loading

0 comments on commit 022f343

Please sign in to comment.