GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-103636: add enums for days and months in calendar module by Agent-Hellboy · Pull Request #103642 · python/cpython

Conversation

@Agent-Hellboy

@Agent-Hellboy Agent-Hellboy commented Apr 20, 2023 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

I have tried to fulfill the requirements from the comments of https://stackoverflow.com/questions/76028482/python-module-defining-constants-for-month-numbers

  • Issue: Convert calendar constants to enums and add months #103636

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot

bedevere-bot commented Apr 20, 2023

Copy link
Copy Markdown

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot mentioned this pull request Apr 20, 2023
Convert calendar constants to enums and add months #103636
Closed
@bedevere-bot bedevere-bot added the awaiting review label Apr 20, 2023
@merwok merwok changed the title gh-103636: Convert Calander consts to enum and add consts for months gh-103636: add enums for days and months in calendar module Apr 20, 2023
@Agent-Hellboy
Agent-Hellboy force-pushed the fix-issue-103636 branch from 32e9466 to 7172358 Compare April 20, 2023 05:18
@bedevere-bot

bedevere-bot commented Apr 20, 2023

Copy link
Copy Markdown

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

sunmy2019
sunmy2019 requested changes Apr 20, 2023
View reviewed changes
Comment thread Lib/calendar.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/calendar.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot added awaiting core review and removed awaiting review labels Apr 20, 2023
@arhadthedev arhadthedev added the stdlib Standard Library Python modules in the Lib/ directory label Apr 20, 2023
Eclips4
Eclips4 reviewed Apr 20, 2023
View reviewed changes
Comment thread Lib/calendar.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

TeamSpen210
TeamSpen210 reviewed Apr 20, 2023
View reviewed changes
Comment thread Lib/calendar.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

bedevere-bot commented Apr 20, 2023

Copy link
Copy Markdown

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Agent-Hellboy
Agent-Hellboy force-pushed the fix-issue-103636 branch from 1ca6a98 to ac4867c Compare April 20, 2023 07:35
@bedevere-bot

bedevere-bot commented Apr 20, 2023

Copy link
Copy Markdown

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Agent-Hellboy
Agent-Hellboy force-pushed the fix-issue-103636 branch from ac4867c to 5cacc5a Compare April 20, 2023 07:37
@bedevere-bot

bedevere-bot commented Apr 20, 2023

Copy link
Copy Markdown

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ethanfurman
ethanfurman requested changes Apr 20, 2023
View reviewed changes
Comment thread Lib/calendar.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/calendar.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/calendar.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the awaiting core review label Apr 20, 2023
@bedevere-bot

bedevere-bot commented Apr 20, 2023

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot added the awaiting changes label Apr 20, 2023
@Agent-Hellboy
Agent-Hellboy force-pushed the fix-issue-103636 branch from 5cacc5a to 97a6011 Compare April 20, 2023 19:32
@bedevere-bot

bedevere-bot commented Apr 20, 2023

Copy link
Copy Markdown

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Agent-Hellboy

Agent-Hellboy commented Apr 20, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again
and I have kept

# Constants for months referenced later
January = 1
February = 2

as it is

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Agent-Hellboy
Agent-Hellboy force-pushed the fix-issue-103636 branch from 97a6011 to c74af07 Compare April 20, 2023 19:38
@bedevere-bot

bedevere-bot commented Apr 20, 2023

Copy link
Copy Markdown

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Agent-Hellboy

Agent-Hellboy commented Apr 20, 2023

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot added awaiting change review and removed awaiting changes labels Apr 20, 2023
@bedevere-bot

bedevere-bot commented Apr 20, 2023

Copy link
Copy Markdown

Thanks for making the requested changes!

@ethanfurman: please review the changes made to this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

blurb-it Bot and others added 2 commits April 22, 2023 07:53
@blurb-it @Agent-Hellboy
fix spelling mistake and modify news entry
3aac302
@Agent-Hellboy
Merge branch 'fix-issue-103636' of https://github.com/Agent-Hellboy/c…
ec8ee98
…python into fix-issue-103636
@sunmy2019

sunmy2019 commented Apr 22, 2023

Copy link
Copy Markdown
Member

what should I do?

If you think test cases are necessary, add what you expect users to do.
eg.

for m in Month:
    calendar.weekday(2021, m, 2) == calendar.weekday(2021, m.value, 2)

though I think this change is okay with no test case.

Agent-Hellboy reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Agent-Hellboy

Agent-Hellboy commented Apr 22, 2023

Copy link
Copy Markdown
Contributor Author

though I think this change is okay with no test case.

Yes, if you want i can change the return type of function returning 0-6 for days to enum , if not then i guess this is okay without test.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Agent-Hellboy

Agent-Hellboy commented Apr 22, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Hi @sunmy2019 , @hugovk
should we raise a deprecation warning for January, February

deprecated_names = ['January','February']

def __getattr__(name):
    print(name)
    if name in deprecated_names:
        warnings.warn(f"{name} is deprecated", DeprecationWarning)
    return name  

I picked the code from https://peps.python.org/pep-0562/

why name is picking __path__?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sunmy2019

sunmy2019 commented Apr 22, 2023

Copy link
Copy Markdown
Member

Hi @sunmy2019 , @hugovk should we raise a deprecation warning for January, February

The question is, are we gonna deprecate these two names.


My opinion:

I think it's better to directly remove January and February since they weren't in __all__ before. They are never in the public API.

We don't need to provide compatibility over non-public names unless it is widely used by others. No one should use these names since only 2 of the 12 months exist.


But since @ethanfurman requested "as-is". I would interpret it as "Do not change these things, and we are not going to deprecate them for compatibility".

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Agent-Hellboy

Agent-Hellboy commented Apr 22, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

But since @ethanfurman requested "as-is". I would interpret it as "Do not change these things, and we are not going to deprecate them for compatibility".

okay, sure

Btw, I got it why doesn't it works in Python 3.12, __getattr__ is not getting called for module-level attributes

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ambv
Merge branch 'main' into fix-issue-103636
fb66466
@ambv

ambv commented Apr 25, 2023

Copy link
Copy Markdown
Contributor

The "DO-NOT-MERGE / unresolved review" check is there to denote outstanding red code review.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ethanfurman

ethanfurman commented Apr 25, 2023

Copy link
Copy Markdown
Member

But since @ethanfurman requested "as-is". I would interpret it as "Do not change these things, and we are not going to deprecate them for compatibility".

My apologies, that was a misunderstanding -- I meant the initial change was fine as-is (in other words, no need to make the same change as above by iterating directly over Month).

Please put that change back in place, and remove the January and February constants.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ethanfurman
ethanfurman requested changes Apr 25, 2023
View reviewed changes

@ethanfurman ethanfurman left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Please restore the change I had confusingly labeled "leave as-is" and remove the January and February constants.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting changes and removed awaiting change review labels Apr 25, 2023
@bedevere-bot

bedevere-bot commented Apr 25, 2023

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Agent-Hellboy added 2 commits April 25, 2023 06:52
@Agent-Hellboy
Remove January and February Constants
ca97985
@Agent-Hellboy
Revert accidental removal of a comment
a2b14db
@Agent-Hellboy

Agent-Hellboy commented Apr 25, 2023

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

I guess the below error is not related to the change

D:\a\1\s\Modules\_tkinter.c(53,10): fatal  error C1083: Cannot open include file: 'tcl.h': No such file or directory [D:\a\1\s\PCbuild\_tkinter.vcxproj]
D:\a\1\s\Modules\tkappinit.c(16,10): fatal  error C1083: Cannot open include file: 'tcl.h': No such file or directory [D:\a\1\s\PCbuild\_tkinter.vcxproj]
    0 Warning(s)
    75 Error(s)

Time Elapsed 00:04:34.47
##[error]Cmd.exe exited with code '1'.
Finishing: Build CPython
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot added awaiting change review and removed awaiting changes labels Apr 25, 2023
@bedevere-bot

bedevere-bot commented Apr 25, 2023

Copy link
Copy Markdown

Thanks for making the requested changes!

@ethanfurman: please review the changes made to this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot
bedevere-bot requested a review from ethanfurman April 25, 2023 02:06
ethanfurman
ethanfurman reviewed Apr 25, 2023
View reviewed changes

@ethanfurman ethanfurman left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Looks good! We can commit what you've done so far, or, if you want to keep going, you can modify any function that is currently just returning an int to return the appropriate Month or Day instead.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Agent-Hellboy

Agent-Hellboy commented Apr 25, 2023

Copy link
Copy Markdown
Contributor Author

Thanks @ethanfurman, I can create a new PR for the same

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ethanfurman
ethanfurman approved these changes Apr 25, 2023
View reviewed changes
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting change review labels Apr 25, 2023
@ethanfurman
ethanfurman merged commit b934f97 into python:main Apr 25, 2023
@bedevere-bot bedevere-bot removed the awaiting merge label Apr 25, 2023
@Agent-Hellboy Agent-Hellboy mentioned this pull request Apr 25, 2023
Return newly added Enum constants for month and days in calendar module #103822
Closed
@hugovk hugovk mentioned this pull request Apr 26, 2023
gh-103636: issue warning for deprecated calendar constants #103833
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@hugovk hugovk hugovk left review comments
@AA-Turner AA-Turner AA-Turner left review comments
@sunmy2019 sunmy2019 sunmy2019 requested changes
@Eclips4 Eclips4 Eclips4 left review comments
@ethanfurman ethanfurman ethanfurman approved these changes
+1 more reviewer
@TeamSpen210 TeamSpen210 TeamSpen210 left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

stdlib Standard Library Python modules in the Lib/ directory

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

10 participants

@Agent-Hellboy @bedevere-bot @AA-Turner @sunmy2019 @ambv @ethanfurman @hugovk @TeamSpen210 @Eclips4 @arhadthedev
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.