Skip to content

Docs: Fix TextCalendar.formatweek() and formatmonthname() signatures - #159516

Open
abhishekacharya200 wants to merge 1 commit into
python:mainfrom
abhishekacharya200:docs-calendar-textcalendar-signatures
Open

abhishekacharya200 wants to merge 1 commit into
python:mainfrom
abhishekacharya200:docs-calendar-textcalendar-signatures

Conversation

@abhishekacharya200

Copy link
Copy Markdown
Contributor

The documented signatures of TextCalendar.formatweek() and TextCalendar.formatmonthname() don't match the code. In both methods width is a required argument:

def formatweek(self, theweek, width): ...
def formatmonthname(self, theyear, themonth, width, withyear=True): ...

The docs show formatweek(theweek, w=0) and formatmonthname(theyear, themonth, width=0, withyear=True). If you follow them, you get errors:

>>> import calendar
>>> c = calendar.TextCalendar()
>>> week = c.monthdays2calendar(2026, 10)[0]
>>> c.formatweek(week)
TypeError: TextCalendar.formatweek() missing 1 required positional argument: 'width'
>>> c.formatweek(week, w=3)
TypeError: TextCalendar.formatweek() got an unexpected keyword argument 'w'
>>> c.formatmonthname(2026, 10)
TypeError: TextCalendar.formatmonthname() missing 1 required positional argument: 'width'

This PR changes the two signatures to match the code and rewords the formatweek() description to use width. It only touches the docs, so I think it needs the "skip news" label.

Both methods require the width argument; the documented defaults (w=0 and width=0) do not exist, and formatweek() has no 'w' parameter.
@bedevere-app bedevere-app Bot added awaiting review docs Documentation in the Doc dir skip news labels Oct 16, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs Oct 16, 2026
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #35189190 | 📁 Comparing 3a162e2 against main (21a36aa)

  🔍 Preview build  

1 file changed
± library/calendar.html

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

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant