#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.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107019166ca7310-f5e770cf-8e82-47c4-aa8e-296ed32e54b0-000000%40eu-central-1.amazonses.com.