Code of Conduct
Feature Description
Create an (int) enum for verbosity options in Django management commands.
This would be an optional feature for those who prefer a mapped value over a magic number. It would only affect Python code, as an add-on, and would not break existing management calls.
Problem
There is currently no default mapping for verbosity levels: only the numbers 0 to 4 are provided via the default management command option verbosity.
Using numbers directly does not clarify their meaning. They also trigger "magic number" warnings in linters.
Providing a standardized mapping in Django Core would:
- More clearly define the meaning of each value.
- Make verbosity-based if-statements more descriptive code.
- Allow reusability of the values in documentation and tutorials.
- Fix magic number warnings in linters and code other quality checkers.
- Prevent developers from having to define such an enum themselves in their projects.
Request or proposal
request
Additional Details
Originally posted on the Django Forum: Should management command verbosity levels be labelled?.
Implementation Suggestions
Based on the current levels described in management help commands, the enum could look like this:
from enum import IntEnum
class Verbosity(IntEnum):
MINIMAL = 0
NORMAL = 1
VERBOSE = 2
VERY_VERBOSE = 3
Names chosen per the help output for the verbosity argument:
-v, --verbosity {0,1,2,3}
Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output
Code of Conduct
Feature Description
Create an (int) enum for verbosity options in Django management commands.
This would be an optional feature for those who prefer a mapped value over a magic number. It would only affect Python code, as an add-on, and would not break existing management calls.
Problem
There is currently no default mapping for verbosity levels: only the numbers 0 to 4 are provided via the default management command option
verbosity.Using numbers directly does not clarify their meaning. They also trigger "magic number" warnings in linters.
Providing a standardized mapping in Django Core would:
Request or proposal
request
Additional Details
Originally posted on the Django Forum: Should management command verbosity levels be labelled?.
Implementation Suggestions
Based on the current levels described in management help commands, the enum could look like this:
Names chosen per the help output for the verbosity argument:
-v, --verbosity {0,1,2,3} Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output