Ensure configuration behavior is predictable, validated, and migration-friendly:
get() patterns when the option is already defined).ImproperlyConfigured rather than using silent fallbacks). If a setting is expected to be callable/type-specific, check it.Example (fail-fast validation for a config-provided function):
from celery.exceptions import ImproperlyConfigured
repr_function = self.app.conf.task_args_repr_function
if not repr_function:
raise ImproperlyConfigured("task_args_repr_function must be set")
if isinstance(repr_function, str):
# resolve symbol_by_name(...)
repr_function = symbol_by_name(repr_function)
if not callable(repr_function):
raise ImproperlyConfigured("task_args_repr_function must be callable")
Example (explicit precedence):
broker_url or CELERY_BROKER_*_URL wins, implement that order consistently, and ensure it’s documented as a behavior contract.Enter the URL of a public GitHub repository