#26315: Allow call_command() to accept a Command object as the first argument
-------------------------------------+-------------------------------------
Reporter: Jon Dufresne | Owner: nobody
Type: New feature | Status: new
Component: Testing framework | Version: master
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 Melvyn Sopacua):
* status: closed => new
* resolution: fixed =>
Comment:
Replying to [comment:4 Tim Graham <timograham@…>]:
> In [changeset:"1845bc1d1007751a7f65c66aeddc35f032f6bf41" 1845bc1d]:
> {{{
> #!CommitTicketReference repository=""
revision="1845bc1d1007751a7f65c66aeddc35f032f6bf41"
> Refs #26315 -- Cleaned up argparse options in commands.
>
> * Removed type coercion. Options created by argparse are already coerced
> to the correct type.
> * Removed fallback default values. Options created by argparse already
> have a default value.
> * Used direct indexing. Options created by argparse are always set. This
> eliminates the need to use dict.get().
> }}}
The final statement is untrue. Various management commands from reusable
apps are now failing (most notably Mezzanine and django-extensions),
because they invoke:
{{{#!python
call_command('name', options_i_know_about=value)
}}}
Evident
[https://bitbucket.org/stephenmcd/mezzanine/src/82939507b6dc2519161db6ee49fec1bd194520de/mezzanine/core/management/commands/createdb.py?at=default&fileviewer
=file-view-default#createdb.py-48 here].
This means those commands blow up on `options['no_color']` with a
`KeyError`. When the exception is caught and reformatted things get worse,
like
[https://bitbucket.org/stephenmcd/mezzanine/src/82939507b6dc2519161db6ee49fec1bd194520de/mezzanine/utils/docs.py?at=default&fileviewer
=file-view-default#docs.py-259 here], where the resulting error message
(Couldn't build model_graph, graph_models failed on: 'no_color') made me
think of lacking LCMS support in Pillow.
I'm proposing a temporary fix to check if all "options created by
argparse" - in fact being the options that should always be supported on
any management command are in fact present in the passed in options dict
and if not issue a `DeprecationWarning` that calling call_command()
without passing the original options dictionary will be unsupported in the
future.
--
Ticket URL: <https://code.djangoproject.com/ticket/26315#comment:5>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.f169801a87fd856b3d8c28bc22d8473e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.