Opened 8 months ago
Last modified 28 hours ago
#36376 assigned Bug
Respect --no-color for command help on python 3.14
| Reported by: | Adam Johnson | Owned by: | Sachi Jain |
|---|---|---|---|
| Component: | Core (Management commands) | Version: | 6.0 |
| Severity: | Release blocker | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | yes |
| 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 (11)
comment:1 by , 8 months ago
| Description: | modified (diff) |
|---|
comment:2 by , 8 months ago
| Summary: | Use argparse color on Python 3.14+ → Use argparse colorized help on Python 3.14+ |
|---|
comment:3 by , 8 months ago
| Triage Stage: | Unreviewed → Someday/Maybe |
|---|---|
| Type: | Uncategorized → New feature |
comment:4 by , 3 months ago
| Has patch: | set |
|---|---|
| Patch needs improvement: | set |
comment:5 by , 3 months ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
comment:6 by , 2 months ago
| Triage Stage: | Someday/Maybe → Accepted |
|---|
comment:8 by , 3 days ago
| Patch needs improvement: | unset |
|---|
comment:9 by , 33 hours ago
| Keywords: | 6.1 removed |
|---|---|
| Patch needs improvement: | set |
| Severity: | Normal → Release blocker |
| Summary: | Use argparse colorized help on Python 3.14+ → Respect --no-color for command help on python 3.14 |
| Type: | New feature → Bug |
| Version: | dev → 5.2 |
Before 3.14 final, Python decided to colorize by default. So rather than opting into the future here, we're left with just the bugfix to make --no-color and DJANGO_COLORS=nocolor work correctly on Python 3.14.
I'd even backport this as a bug in the support for 3.14.
comment:10 by , 33 hours ago
| Needs documentation: | set |
|---|---|
| Version: | 5.2 → 6.0 |
That said, I don't think we have to backport all the way to 5.2 necessarily. I'm open to advice.
comment:11 by , 28 hours ago
I think I would backport it as a bugfix. Disabling colourization is sometimes important for accessibility or CI scripts, and leaving users who upgrade to Python 3.14 with new colours they can't disable feels like a minor bug to me.
Note that Python 3.14 is scheduled for October 1st (see #35844)