Skip to content

Improve argparse documentation about controlling color #140693

Closed

Description

@savannahostrowski

Related to #139946 (comment), we should improve argparse documentation to clarify the order of precedence of controlling color by expanding this section a bit https://docs.python.org/3/library/argparse.html#color.

Some notes to get started:

  • Environment variables take precedence over color=True, but color=False takes precedence.
  • Users can control global color settings via NO_COLOR or FORCE_COLOR etc.

Linked PRs

Activity

  1. added
    docs
    stdlib
    3.14
    3.15
    on Oct 28, 2025
  2. XChaitanyaX commented on Oct 28, 2025

    @XChaitanyaX
    Contributor

    Working on this..

  3. XChaitanyaX commented on Oct 28, 2025

    @XChaitanyaX
    Contributor

    Really, what we want to spell out is that env vars take precedence over anything set in the parser.

    Why does FORCE_COLOR = "1" and color=False does not give colored output??

  4. savannahostrowski commented on Oct 28, 2025

    @savannahostrowski
    MemberAuthor

    Sorry, that's a typo. Below that, I have a note that color=False actually takes precedence.

    Environment variables take precedence over color=True, but color=False takes precedence.

    It's worth tracing through the code, though, as you update the docs. I think there may be more context worth adding as well.

  5. hugovk commented on Oct 28, 2025

    @hugovk
    Member

    Note https://docs.python.org/3/using/cmdline.html#using-on-controlling-color details the precedence of the env vars, so we can refer to that.

    And in originally implementing, I also aimed to follow https://no-color.org/ about color=, see FAQ 2: "How should configuration files and command-line arguments be processed in the presence of NO_COLOR?"

  6. added a commit that references this issue on Nov 2, 2025
  7. added a commit that references this issue on Nov 3, 2025
  8. added a commit that references this issue on Nov 3, 2025
  9. added a commit that references this issue on Dec 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.143.15docseasystdlib

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions