[Django] #36376: Use argparse color on Python 3.14+

5 views
Skip to first unread message

Django

unread,
May 8, 2025, 6:21:42 AM5/8/25
to django-...@googlegroups.com
#36376: Use argparse color on Python 3.14+
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Type:
| Uncategorized
Status: new | Component: Core
| (Management commands)
Version: dev | Severity: Normal
Keywords: 6.1 | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Python 3.14 introduces colorized help to argparse:
https://docs.python.org/3.14/library/argparse.html#color

I propose that we enable this attribute 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`,
[https://docs.djangoproject.com/en/5.2/ref/django-admin/#syntax-coloring
as already documented].

We may also be able to set the option when
[https://docs.djangoproject.com/en/5.2/ref/django-admin/#cmdoption-force-
color `--force-color`] is passed, although that may not make sense when
`--help` is passed.

Related: #36321
--
Ticket URL: <https://code.djangoproject.com/ticket/36376>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 8, 2025, 6:22:17 AM5/8/25
to django-...@googlegroups.com
#36376: Use argparse color on Python 3.14+
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: (none)
Type: Uncategorized | Status: new
Component: Core (Management | Version: dev
commands) |
Severity: Normal | Resolution:
Keywords: 6.1 | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Adam Johnson:

Old description:

> Python 3.14 introduces colorized help to argparse:
> https://docs.python.org/3.14/library/argparse.html#color
>
> I propose that we enable this attribute 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`,
> [https://docs.djangoproject.com/en/5.2/ref/django-admin/#syntax-coloring
> as already documented].
>
> We may also be able to set the option when
> [https://docs.djangoproject.com/en/5.2/ref/django-admin/#cmdoption-force-
> color `--force-color`] is passed, although that may not make sense when
> `--help` is passed.
>
> Related: #36321

New description:

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`,
[https://docs.djangoproject.com/en/5.2/ref/django-admin/#syntax-coloring
as already documented].

We may also be able to set the option when
[https://docs.djangoproject.com/en/5.2/ref/django-admin/#cmdoption-force-
color `--force-color`] is passed, although that may not make sense when
`--help` is passed.

Related: #36321

--
--
Ticket URL: <https://code.djangoproject.com/ticket/36376#comment:1>
Reply all
Reply to author
Forward
0 new messages