#35689: `LabelCommand`: `label` does not affect the `missing_args_message`
-------------------------------------+-------------------------------------
Reporter: Kamil Paduszyński | Type: Bug
Status: new | Component: Core
| (Management commands)
Version: 5.1 | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
The `missing_args_message` attribute of the
`django.core.management.base.LabelCommand` is hard coded using the default
value of `label = "label"`.
I would suggest the following update:
{{{#!python
class LabelCommand(BaseCommand):
label = "label"
missing_args_message = "Enter at least one %s."
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.missing_args_message = (
(missing_args_message % self.label)
if (missing_args_message := self.missing_args_message) is not
None
else None
)
}}}
Of course, I am open to refactoring - a single, complex though,
conditional assignment allows for avoiding branching.
It can be tested by updating the `test_label_command_no_label` case.
--
Ticket URL: <
https://code.djangoproject.com/ticket/35689>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.