Skip to content

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

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

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

Conversation

@hugovk

@hugovkhugovk commented Apr 10, 2026

Copy link
Copy Markdown
Member

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

Let's add a touch more colour.

Before After
ImageImage

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

@hugovk
hugovk requested a review from AA-Turner as a code ownerApril 10, 2026 17:27
@hugovkhugovk added the stdlib Standard Library Python modules in the Lib/ directory label Apr 10, 2026
Comment threadDoc/library/calendar.rst Outdated
Co-authored-by: Rihaan Meher <sharktidedev@gmail.com>
Comment threadMisc/NEWS.d/next/Library/2026-04-10-20-23-22.gh-issue-148352.lrec3W.rst Outdated
Comment threadLib/calendar.py
@sharktide

This comment was marked as resolved.

Co-authored-by: Rihaan Meher <sharktidedev@gmail.com>

@sharktidesharktide left a comment

Copy link
Copy Markdown
Contributor

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 threadLib/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
MemberAuthor

Choose a reason for hiding this comment

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

Removed!

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
MemberAuthor

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

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
MemberAuthor

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.

@StanFromIrelandStanFromIreland left a comment

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.

LGTM :-) 🌈

@hugovk
hugovk merged commit 2ba0a81 into python:mainMay 4, 2026
64 checks passed
@hugovk
hugovk deleted the 3.15-calendar-colour branch May 4, 2026 12:15
@hugovk

Copy link
Copy Markdown
MemberAuthor

Thanks @sharktide and @StanFromIreland for the reviews!

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

Labels

stdlibStandard Library Python modules in the Lib/ directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@hugovk@sharktide@StanFromIreland