[New-bugs-announce] [issue46266] Improve day constants (`MONDAY` ... `SUNDAY`) in `calendar.py`

Nikita Sobolev report at bugs.python.org
Wed Jan 5 04:38:22 EST 2022


New submission from Nikita Sobolev <mail at sobolevn.me>:

For some reasons useful day constants (`MONDAY` ... `SUNDAY`) from `calendar` are not properly recognised.

Several problems:
0. Not all code inside uses these constants
1. They are not tested. Only `.MONDAY` and `.SUNDAY` are tested to be present in https://github.com/python/cpython/blob/main/Lib/test/test_calendar.py#L508-L511
2. They are not in `__all__`
3. They are partially documented. There are some notes about them in https://docs.python.org/3/library/calendar.html#calendar.setfirstweekday

> Sets the weekday (0 is Monday, 6 is Sunday) to start each week. The values :const:`MONDAY`, :const:`TUESDAY`, :const:`WEDNESDAY`, :const:`THURSDAY`, :const:`FRIDAY`, :const:`SATURDAY`, and :const:`SUNDAY` are provided for convenience. For example, to set the first weekday to Sunday:

>    import calendar
>    calendar.setfirstweekday(calendar.SUNDAY)

But, they are not clickable, because, for example, ":const:`MONDAY`" does not exist in docs index.

So, my plan is:
0. Improve constant usage in the source code to make it more readable
1. Test that constants are there
2. Add them to `__all__` as a part of public API
3. Improve their docs

----------
components: Library (Lib)
messages: 409742
nosy: sobolevn
priority: normal
severity: normal
status: open
title: Improve day constants (`MONDAY` ... `SUNDAY`) in `calendar.py`
type: behavior
versions: Python 3.10, Python 3.11, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46266>
_______________________________________


More information about the New-bugs-announce mailing list