[Django] #30763: call_command fails when argument of mutually exclusive group is passed through keyword arguments

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[Django] #30763: call_command fails when argument of mutually exclusive group is passed through keyword arguments

Django
#30763: call_command fails when argument of mutually exclusive group is passed
through keyword arguments
-------------------------------------+-------------------------------------
               Reporter:  OkThought  |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Component:  Core       |        Version:  2.2
  (Management commands)              |       Keywords:  call_command
               Severity:  Normal     |  required mutually exclusive group
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 This error
 {{{
 django.core.management.base.CommandError: Error: one of the arguments
 --shop-id --shop is required
 }}}
 is raised when I run
 {{{
 call_command('my_command', shop_id=1)
 }}}
 the argument 'shop_id' is part of a required mutually exclusive group:
 {{{
 shop = parser.add_mutually_exclusive_group(required=True)
 shop.add_argument('--shop-id', nargs='?', type=int, default=None,
 dest='shop_id')
 shop.add_argument('--shop', nargs='?', type=str, default=None,
 dest='shop_name')
 }}}

 However, everything is fine when I call this command in this way:
 {{{
 call_command('my_command, '--shop-id=1')
 }}}

 In django sources I found that only those keyword arguments of
 call_command are passed to the parser that are defined as required:
 {{{
 # Any required arguments which are passed in via '**options' must be
 passed
 # to parse_args().
 parse_args += [
     '{}={}'.format(min(opt.option_strings), arg_options[opt.dest])
     for opt in parser._actions if opt.required and opt.dest in options
 ]
 }}}
 but in this special case both of them individually are not required, they
 are actually part of a group that is required. And the code of
 call_command does nothing with groups defined in the parser.

--
Ticket URL: <https://code.djangoproject.com/ticket/30763>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/052.20a23270280acddc83188f61feac4e53%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30763: call_command fails when argument of required mutually exclusive group is passed in kwargs. (was: call_command fails when argument of mutually exclusive group is passed through keyword arguments)

Django
#30763: call_command fails when argument of required  mutually exclusive group is
passed in kwargs.
-------------------------------------+-------------------------------------
     Reporter:  OkThought            |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Core (Management     |                  Version:  master
  commands)                          |
     Severity:  Normal               |               Resolution:
     Keywords:  call_command         |             Triage Stage:  Accepted
  required mutually exclusive group  |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by felixxm):

 * cc: Hasan Ramezani (added)
 * version:  2.2 => master
 * stage:  Unreviewed => Accepted


Comment:

 Thanks for this report. I attached a simple test.

 Reproduced at ed2d411aa84efc76baba3adf0d0f99df0e44ba57.

--
Ticket URL: <https://code.djangoproject.com/ticket/30763#comment:1>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.be87c4a0e25b5d97abe6a90725092261%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30763: call_command fails when argument of required mutually exclusive group is passed in kwargs.

Django
In reply to this post by Django
#30763: call_command fails when argument of required  mutually exclusive group is
passed in kwargs.
-------------------------------------+-------------------------------------
     Reporter:  OkThought            |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Core (Management     |                  Version:  master
  commands)                          |
     Severity:  Normal               |               Resolution:
     Keywords:  call_command         |             Triage Stage:  Accepted
  required mutually exclusive group  |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by felixxm):

 * Attachment "test-30763.diff" added.


--
Ticket URL: <https://code.djangoproject.com/ticket/30763>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.5f8a6213859171390147a9811153cdf9%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30763: call_command fails when argument of required mutually exclusive group is passed in kwargs.

Django
In reply to this post by Django
#30763: call_command fails when argument of required  mutually exclusive group is
passed in kwargs.
-------------------------------------+-------------------------------------
     Reporter:  OkThought            |                    Owner:  Hasan
                                     |  Ramezani
         Type:  Bug                  |                   Status:  assigned
    Component:  Core (Management     |                  Version:  master
  commands)                          |
     Severity:  Normal               |               Resolution:
     Keywords:  call_command         |             Triage Stage:  Accepted
  required mutually exclusive group  |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

 * owner:  nobody => Hasan Ramezani
 * status:  new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/30763#comment:2>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.7e0c051a7b4594a2a2fd22a48fc0eb3c%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30763: call_command fails when argument of required mutually exclusive group is passed in kwargs.

Django
In reply to this post by Django
#30763: call_command fails when argument of required  mutually exclusive group is
passed in kwargs.
-------------------------------------+-------------------------------------
     Reporter:  Ivan Bogush          |                    Owner:  Hasan
                                     |  Ramezani
         Type:  Bug                  |                   Status:  assigned
    Component:  Core (Management     |                  Version:  master
  commands)                          |
     Severity:  Normal               |               Resolution:
     Keywords:  call_command         |             Triage Stage:  Accepted
  required mutually exclusive group  |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

 * has_patch:  0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/30763#comment:3>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.41a91a60ce4c445b4e7f26ea275830d6%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30763: call_command fails when argument of required mutually exclusive group is passed in kwargs.

Django
In reply to this post by Django
#30763: call_command fails when argument of required  mutually exclusive group is
passed in kwargs.
-------------------------------------+-------------------------------------
     Reporter:  Ivan Bogush          |                    Owner:  Hasan
                                     |  Ramezani
         Type:  Bug                  |                   Status:  closed
    Component:  Core (Management     |                  Version:  master
  commands)                          |
     Severity:  Normal               |               Resolution:  fixed
     Keywords:  call_command         |             Triage Stage:  Accepted
  required mutually exclusive group  |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

 In [changeset:"6c379f1a1897a0e0b95531ea7d9806b17b22ff89" 6c379f1]:
 {{{
 #!CommitTicketReference repository=""
 revision="6c379f1a1897a0e0b95531ea7d9806b17b22ff89"
 Fixed #30763 -- Fixed management commands when using required mutually
 exclusive groups.
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30763#comment:4>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.c18c0a31435294731e7aeb85f6e9dc64%40djangoproject.com.