Opened 4 months ago

Last modified 4 months ago

#36376 new New feature

Use argparse colorized help on Python 3.14+

Reported by: Adam Johnson Owned by:
Component: Core (Management commands) Version: dev
Severity: Normal Keywords: 6.1
Cc: Triage Stage: Someday/Maybe
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
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 (3)

comment:1 by Adam Johnson, 4 months ago

Description: modified (diff)

comment:2 by Adam Johnson, 4 months ago

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

comment:3 by Sarah Boyce, 4 months ago

Triage Stage: UnreviewedSomeday/Maybe
Type: UncategorizedNew feature

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

Note: See TracTickets for help on using tickets.
Back to Top