Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert calendar constants to enums and add months #103636

Closed
ethanfurman opened this issue Apr 19, 2023 · 8 comments
Closed

Convert calendar constants to enums and add months #103636

ethanfurman opened this issue Apr 19, 2023 · 8 comments
Labels
3.12 bugs and security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@ethanfurman
Copy link
Member

ethanfurman commented Apr 19, 2023

From this discuss thread:

The calendar module already defines constants e.g. MONDAY (0), TUESDAY (1), etc. for the [days of the week] https://docs.python.org/3/library/calendar.html#calendar.MONDAY).

Since these are likely to be commonly needed too, would it make sense for the calendar module to also export constants for all of JANUARY (1), FEBRUARY (2), …, DECEMBER (12)?

This would allow one to write from calendar import APRIL and then e.g. use APRIL instead of 4 when building a datetime.date object.

Related: datetime - Python module defining constants for month numbers? - Stack Overflow

Linked PRs

@ethanfurman ethanfurman added type-feature A feature request or enhancement stdlib Python modules in the Lib dir 3.12 bugs and security fixes labels Apr 19, 2023
@Agent-Hellboy
Copy link
Contributor

looks easy, I would like to raise a PR?

@ethanfurman
Copy link
Member Author

@Agent-Hellboy Please do!

@Agent-Hellboy
Copy link
Contributor

Sure😊

Agent-Hellboy added a commit to Agent-Hellboy/cpython that referenced this issue Apr 20, 2023
Agent-Hellboy added a commit to Agent-Hellboy/cpython that referenced this issue Apr 20, 2023
Agent-Hellboy added a commit to Agent-Hellboy/cpython that referenced this issue Apr 20, 2023
Agent-Hellboy added a commit to Agent-Hellboy/cpython that referenced this issue Apr 20, 2023
Agent-Hellboy added a commit to Agent-Hellboy/cpython that referenced this issue Apr 20, 2023
Agent-Hellboy added a commit to Agent-Hellboy/cpython that referenced this issue Apr 20, 2023
Agent-Hellboy added a commit to Agent-Hellboy/cpython that referenced this issue Apr 21, 2023
@Sergo2106

This comment was marked as off-topic.

Agent-Hellboy added a commit to Agent-Hellboy/cpython that referenced this issue Apr 21, 2023
ethanfurman pushed a commit that referenced this issue Apr 25, 2023
Convert day contants to a Day enum, and add a Month enum.
@ethanfurman
Copy link
Member Author

Let's also add a module-level __getattr__ to provide the January and February constants and issue a warning when that happens.

@Agent-Hellboy
Copy link
Contributor

okay, I will create a PR

@hugovk
Copy link
Member

hugovk commented Apr 26, 2023

Let's also document the additions from #103642 at https://docs.python.org/3.12/library/calendar.html with a .. versionadded:: 3.12, and also add to https://docs.python.org/3.12/whatsnew/3.12.html#improved-modules

hugovk added a commit that referenced this issue Apr 29, 2023
Co-authored-by: Hugo van Kemenade <[email protected]>
Co-authored-by: Éric <[email protected]>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
@hugovk
Copy link
Member

hugovk commented Apr 29, 2023

@hugovk hugovk closed this as completed Apr 29, 2023
carljm added a commit to carljm/cpython that referenced this issue May 1, 2023
* main: (26 commits)
  pythongh-104028: Reduce object creation while calling callback function from gc (pythongh-104030)
  pythongh-104036: Fix direct invocation of test_typing (python#104037)
  pythongh-102213: Optimize the performance of `__getattr__` (pythonGH-103761)
  pythongh-103895: Improve how invalid `Exception.__notes__` are displayed (python#103897)
  Adjust expression from `==` to `!=` in alignment with the meaning of the paragraph. (pythonGH-104021)
  pythongh-88496: Fix IDLE test hang on macOS (python#104025)
  Improve int test coverage (python#104024)
  pythongh-88773: Added teleport method to Turtle library (python#103974)
  pythongh-104015: Fix direct invocation of `test_dataclasses` (python#104017)
  pythongh-104012: Ensure test_calendar.CalendarTestCase.test_deprecation_warning consistently passes (python#104014)
  pythongh-103977: compile re expressions in platform.py only if required (python#103981)
  pythongh-98003: Inline call frames for CALL_FUNCTION_EX (pythonGH-98004)
  Replace Netlify with Read the Docs build previews (python#103843)
  Update name in acknowledgements and add mailmap (python#103696)
  pythongh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (python#103927)
  Remove non-existing tools from Sundry skiplist (python#103991)
  pythongh-103793: Defer formatting task name (python#103767)
  pythongh-87092: change assembler to use instruction sequence instead of CFG (python#103933)
  pythongh-103636: issue warning for deprecated calendar constants (python#103833)
  Various small fixes to dis docs (python#103923)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 bugs and security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants