Opened 6 months ago
Last modified 2 weeks ago
#36376 assigned New feature
Use argparse color on Python 3.14+ — at Version 1
| Reported by: | Adam Johnson | Owned by: | |
|---|---|---|---|
| Component: | Core (Management commands) | Version: | dev |
| Severity: | Normal | Keywords: | 6.1 |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | yes |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Python 3.14 introduces colorized help to argparse: https://docs.python.org/3.14/library/argparse.html#color
I propose that we enable this feature by setting color=True for all argument parsers in Django, notably for management commands.
Python supports common opt-out environment variables for the feature. I think we’ll need to extend that to also avoid setting the color attribute when DJANGO_COLORS is set to nocolor, as already documented.
We may also be able to set the option when `--force-color` is passed, although that may not make sense when --help is passed.
Related: #36321