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 Adam Johnson)

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 Adam Johnson, 8 months ago

Description: modified (diff)

comment:2 by Adam Johnson, 8 months ago

Summary: Use argparse color on Python 3.14+Use argparse colorized help on Python 3.14+

comment:3 by Sarah Boyce, 8 months ago

Triage Stage: UnreviewedSomeday/Maybe
Type: UncategorizedNew feature

Note that Python 3.14 is scheduled for October 1st (see #35844)

comment:4 by Adam Johnson, 3 months ago

Has patch: set
Patch needs improvement: set

comment:5 by wangxiaolei, 3 months ago

Owner: set to wangxiaolei
Status: newassigned

comment:6 by Jacob Walls, 2 months ago

Triage Stage: Someday/MaybeAccepted

comment:7 by Sachi Jain, 3 days ago

Owner: changed from wangxiaolei to Sachi Jain

comment:8 by Sachi Jain, 3 days ago

Patch needs improvement: unset

comment:9 by Jacob Walls, 33 hours ago

Keywords: 6.1 removed
Patch needs improvement: set
Severity: NormalRelease blocker
Summary: Use argparse colorized help on Python 3.14+Respect --no-color for command help on python 3.14
Type: New featureBug
Version: dev5.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 Jacob Walls, 33 hours ago

Needs documentation: set
Version: 5.26.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 Adam Johnson, 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: See TracTickets for help on using tickets.
Back to Top