Opened 6 months ago
Last modified 2 weeks ago
#36376 assigned New feature
Use argparse colorized help on Python 3.14+
| Reported by: | Adam Johnson | Owned by: | wangxiaolei |
|---|---|---|---|
| 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
Change History (6)
comment:1 by , 6 months ago
| Description: | modified (diff) |
|---|
comment:2 by , 6 months ago
| Summary: | Use argparse color on Python 3.14+ → Use argparse colorized help on Python 3.14+ |
|---|
comment:3 by , 6 months ago
| Triage Stage: | Unreviewed → Someday/Maybe |
|---|---|
| Type: | Uncategorized → New feature |
comment:4 by , 5 weeks ago
| Has patch: | set |
|---|---|
| Patch needs improvement: | set |
comment:5 by , 4 weeks ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
comment:6 by , 2 weeks ago
| Triage Stage: | Someday/Maybe → Accepted |
|---|
Note that Python 3.14 is scheduled for October 1st (see #35844)