FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-103636: add enums for days and months in calendar module by Agent-Hellboy · Pull Request #103642 · python/cpython · GitHub

/ cpython Public

gh-103636: add enums for days and months in calendar module - #103642

Merged
ethanfurman merged 7 commits into
python:mainfrom
Agent-Hellboy:fix-issue-103636
Apr 25, 2023
Merged

gh-103636: add enums for days and months in calendar module#103642
ethanfurman merged 7 commits into
python:mainfrom
Agent-Hellboy:fix-issue-103636

Conversation

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

Copy link
Copy Markdown
Contributor

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.

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

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.

Comment thread Lib/calendar.py Outdated
Comment thread Lib/calendar.py Outdated
arhadthedev added the stdlib Standard Library Python modules in the Lib/ directory label Apr 20, 2023
Comment thread Lib/calendar.py Outdated
Comment thread Lib/calendar.py Outdated

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.

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.

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.

Comment thread Lib/calendar.py Outdated
Comment thread Lib/calendar.py Outdated
Comment thread Lib/calendar.py

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.

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.

Agent-Hellboy commented Apr 20, 2023
edited
Loading

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

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.

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

Copy link
Copy Markdown

Thanks for making the requested changes!

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

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.

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.

Agent-Hellboy commented Apr 22, 2023
edited
Loading

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__?

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".

Agent-Hellboy commented Apr 22, 2023
edited
Loading

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

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.

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.

ethanfurman 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

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.

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

Copy link
Copy Markdown

Thanks for making the requested changes!

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

ethanfurman 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Copy link
Copy Markdown
Contributor Author

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

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stdlib Standard Library Python modules in the Lib/ directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants


Back | FazBrowse Home | New Git URL