[Django] #35689: `LabelCommand`: `label` does not affect the `missing_args_message`

25 views
Skip to first unread message

Django

unread,
Aug 18, 2024, 2:40:35 PM8/18/24
to django-...@googlegroups.com
#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.

Django

unread,
Aug 19, 2024, 2:51:20 AM8/19/24
to django-...@googlegroups.com
#35689: `LabelCommand`: `label` does not affect the `missing_args_message`
-------------------------------------+-------------------------------------
Reporter: Kamil Paduszyński | Owner: (none)
Type: Bug | Status: new
Component: Core (Management | Version: 5.1
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* stage: Unreviewed => Accepted

Comment:

Thank you!
Replicated - example failing test
{{{#!diff
--- a/tests/staticfiles_tests/test_management.py
+++ b/tests/staticfiles_tests/test_management.py
@@ -124,6 +124,11 @@ class TestFindStatic(TestDefaults,
CollectionTestCase):
searched_locations,
)

+ def test_missing_args_message(self):
+ msg = "Enter at least one staticfile."
+ with self.assertRaisesMessage(CommandError, msg):
+ call_command("findstatic")
+
}}}

Would you like to submit a PR?
--
Ticket URL: <https://code.djangoproject.com/ticket/35689#comment:1>

Django

unread,
Aug 20, 2024, 5:38:48 AM8/20/24
to django-...@googlegroups.com
#35689: `LabelCommand`: `label` does not affect the `missing_args_message`
-------------------------------------+-------------------------------------
Reporter: Kamil Paduszyński | Owner: Giovanni
| Fabbretti
Type: Bug | Status: assigned
Component: Core (Management | Version: 5.1
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Giovanni Fabbretti):

* owner: (none) => Giovanni Fabbretti
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/35689#comment:2>

Django

unread,
Aug 20, 2024, 10:34:24 AM8/20/24
to django-...@googlegroups.com
#35689: `LabelCommand`: `label` does not affect the `missing_args_message`
-------------------------------------+-------------------------------------
Reporter: Kamil Paduszyński | Owner: Giovanni
| Fabbretti
Type: Bug | Status: assigned
Component: Core (Management | Version: 5.1
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Giovanni Fabbretti):

* has_patch: 0 => 1

Comment:

Hello,
I have created a [https://github.com/django/django/pull/18500 PR]
implementing the test proposed by Sarah and the solution proposed by
Kamil.
--
Ticket URL: <https://code.djangoproject.com/ticket/35689#comment:3>

Django

unread,
Aug 21, 2024, 9:48:31 AM8/21/24
to django-...@googlegroups.com
#35689: `LabelCommand`: `label` does not affect the `missing_args_message`
-------------------------------------+-------------------------------------
Reporter: Kamil Paduszyński | Owner: Giovanni
| Fabbretti
Type: Bug | Status: assigned
Component: Core (Management | Version: 5.1
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/35689#comment:4>

Django

unread,
Aug 21, 2024, 2:01:11 PM8/21/24
to django-...@googlegroups.com
#35689: `LabelCommand`: `label` does not affect the `missing_args_message`
-------------------------------------+-------------------------------------
Reporter: Kamil Paduszyński | Owner: Giovanni
| Fabbretti
Type: Bug | Status: assigned
Component: Core (Management | Version: 5.1
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 0 => 1
* stage: Ready for checkin => Accepted

--
Ticket URL: <https://code.djangoproject.com/ticket/35689#comment:5>

Django

unread,
Aug 23, 2024, 10:37:19 AM8/23/24
to django-...@googlegroups.com
#35689: `LabelCommand`: `label` does not affect the `missing_args_message`
-------------------------------------+-------------------------------------
Reporter: Kamil Paduszyński | Owner: Giovanni
| Fabbretti
Type: Bug | Status: assigned
Component: Core (Management | Version: 5.1
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/35689#comment:6>

Django

unread,
Aug 23, 2024, 11:26:38 AM8/23/24
to django-...@googlegroups.com
#35689: `LabelCommand`: `label` does not affect the `missing_args_message`
-------------------------------------+-------------------------------------
Reporter: Kamil Paduszyński | Owner: Giovanni
| Fabbretti
Type: Bug | Status: closed
Component: Core (Management | Version: 5.1
commands) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce <42296566+sarahboyce@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"f72bbd44808452f4a70be5f7b9d35e46dee32e2d" f72bbd44]:
{{{#!CommitTicketReference repository=""
revision="f72bbd44808452f4a70be5f7b9d35e46dee32e2d"
Fixed #35689 -- Handled custom labels in
LabelCommand.missing_args_message.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35689#comment:7>
Reply all
Reply to author
Forward
0 new messages