Opened 3 months ago
Closed 2 months ago
#35689 closed Bug (fixed)
`LabelCommand`: `label` does not affect the `missing_args_message`
Reported by: | Kamil Paduszyński | Owned by: | Giovanni Fabbretti |
---|---|---|---|
Component: | Core (Management commands) | Version: | 5.1 |
Severity: | Normal | Keywords: | |
Cc: | Kamil Paduszyński | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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:
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.
Change History (7)
comment:1 by , 3 months ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 2 months ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:3 by , 2 months ago
Has patch: | set |
---|
Hello,
I have created a PR implementing the test proposed by Sarah and the solution proposed by Kamil.
comment:4 by , 2 months ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:5 by , 2 months ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Ready for checkin → Accepted |
comment:6 by , 2 months ago
Patch needs improvement: | unset |
---|---|
Triage Stage: | Accepted → Ready for checkin |
Note:
See TracTickets
for help on using tickets.
Thank you!
Replicated - example failing test
tests/staticfiles_tests/test_management.py
Would you like to submit a PR?