Skip to content

gh-148352: Add more colour to calendar CLI output#148354

Merged
hugovk merged 10 commits intopython:mainfrom
hugovk:3.15-calendar-colour
May 4, 2026
Merged

gh-148352: Add more colour to calendar CLI output#148354
hugovk merged 10 commits intopython:mainfrom
hugovk:3.15-calendar-colour

Conversation

@hugovk
Copy link
Copy Markdown
Member

@hugovk hugovk commented Apr 10, 2026

In Python 3.14, we added an amazing colour highlight for today: #128318.

Let's add a touch more colour.

Before After
Image Image

📚 Documentation preview 📚: https://cpython-previews--148354.org.readthedocs.build/

@hugovk hugovk requested a review from AA-Turner as a code owner April 10, 2026 17:27
@hugovk hugovk added the stdlib Standard Library Python modules in the Lib/ directory label Apr 10, 2026
Comment thread Doc/library/calendar.rst Outdated
Co-authored-by: Rihaan Meher <[email protected]>
Comment thread Misc/NEWS.d/next/Library/2026-04-10-20-23-22.gh-issue-148352.lrec3W.rst Outdated
Comment thread Lib/calendar.py
@sharktide

This comment was marked as resolved.

Co-authored-by: Rihaan Meher <[email protected]>
Copy link
Copy Markdown
Contributor

@sharktide sharktide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @hugovk :)

@johnslavik johnslavik self-requested a review April 14, 2026 23:52
Comment thread Lib/test/test_calendar.py Outdated
@@ -1122,4 +1123,4 @@
self.assertCmdFails(*args)

@support.force_not_colorized
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be removed, no?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed!

Comment thread Lib/test/test_calendar.py
self.assertCmdFails(*args)

@support.force_not_colorized
def test_help(self):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also have a case checking for color?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added!

@read-the-docs-community
Copy link
Copy Markdown

Comment thread Lib/test/test_calendar.py
today = datetime.date(2026, 5, 4)
cal = calendar._CLIDemoCalendar(highlight_day=today)
output = cal.formatmonth(2026, 5)
self.assertIn("\x1b[30m\x1b[43mMay 2026\x1b[0m\n\x1b[36m", output)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, do we support running tests with different themes? If a user has a custom theme this test will fail.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't support running tests with different themes.

Other tests could also break if the user changed the theme:

rg "x1b" Lib/test/test_*.py -l | wc -l
      13

Right now the theme API is internal/private. If we make it public in a later release, we'll need to consider tests are with the default theme or a specific theme.

Copy link
Copy Markdown
Member

@StanFromIreland StanFromIreland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :-) 🌈

@hugovk hugovk merged commit 2ba0a81 into python:main May 4, 2026
64 checks passed
@hugovk hugovk deleted the 3.15-calendar-colour branch May 4, 2026 12:15
@hugovk
Copy link
Copy Markdown
Member Author

hugovk commented May 4, 2026

Thanks @sharktide and @StanFromIreland for the reviews!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stdlib Standard Library Python modules in the Lib/ directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants