Enum for management command verbosity levels
- Dominant language
- No language data
- Stars
- 188
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
### Code of Conduct
- [x] I agree to follow Django's 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:
1. More clearly define the meaning of each value.
2. Make verbosity-based if-statements more descriptive code.
3. Allow reusability of the values in documentation and tutorials.
4. Fix magic number warnings in linters and code other quality checkers.
5. 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?](https://forum.djangoproject.com/t/should-management-command-verbosity-levels-be-labelled/43783).
### Implementation Suggestions
Based on the current levels described in management help commands, the enum could look like this:
```python
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:
```sh
-v, --verbosity {0,1,2,3}
Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.