django icon indicating copy to clipboard operation
django copied to clipboard

Simplified management command option extraction.

Open adamchainz opened this issue 2 years ago • 2 comments

Similar to #15185 , use improvements to Python function signatures where possible. Much of the x = options['x'] pattern has been around since Python 2.

adamchainz avatar Dec 13 '21 16:12 adamchainz

@adamchainz Thanks for this patch :+1: However, is there any reason for this change, except the signature change? Is it backward compatible? Folks use subclasses of builtin commands. Currently I don't see much value in changing these signature.

felixxm avatar Dec 13 '21 17:12 felixxm

I tried sure to be backwards compatible everywhere, sticking with names and not extracting them if **options is passed on.

IMO it's easier to read, and sets examples for how to write management commands efficiently.

It's also better for mistakes where the argparse names don't align with the expected arguments. The error will happen at call time, rather than halfway through handle() when the options['x'] line is finally hit.

adamchainz avatar Dec 13 '21 17:12 adamchainz