Prioritize readability through consistent formatting and modern, simple idioms. For code style changes, ensure multiline constructs are formatted cleanly, complex conditions are made understandable (via extracted “effective” variables or small helpers), repeated patterns are factored out, and modern Python conventions are used.
Apply these practices:
strip() on multiline literals.{} for dict literals, {**d1, **d2} for dict merges, and keep imports ordered (isort).Example (multiline constant + readable conditional):
MAP_ROUTES_MUST_BE_A_DICTIONORY = (
"Starting from Celery 5.1 the task_routes configuration must be a dictionary. "
"Support for providing a list of router objects will be removed in 6.0."
)
effective_exchange = exchange or queue_exchange_name
effective_rkey = routing_key or queue_exchange_routing_key
if not effective_exchange and not effective_rkey and exchange_type == "direct":
# ...
pass
When unsure, prefer the version that is easiest to scan in a code review: small helpers/variables, clear indentation, and minimal unnecessary transformations.
Enter the URL of a public GitHub repository