-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Issue 88: St 8000 ub for calendar module #90
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
Conversation
Rather than writing
please write
Same with None. That way, you also don't run into the missing True/False mypy issue. |
FWIW the issue of missing True/False is because of a recent change to builtin.pyi; there's a matching change needed to mypy but it has not landed yet (python/mypy#1218). |
Note that if you have a |
Also PEP 8 and PEP 484 both say you should put spaces around the equal sign for a default when combined with a type. IOW instead of |
Use Optional[...] when appropriate. Adhere to PEP-484 styling.
Thanks for your comments. I've amended the pull request with another commit. |
YearType = int | ||
MonthType = int | ||
DayType = int | ||
WeekdayType = int |
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.
Honestly I don't think these are very useful -- type checkers don't differentiate between them and the way it's written here these names are exported by the stub (but not by the real module). They just lengthen the signatures.
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.
But I believe that they provide useful information about what the module's functions do, though. For example, by looking at the signature of a method like itermonthdays2
one can immediately tell from the return type that the tuples are made of a day and a weekday (and not the other way around) without having to read the docs.
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.
In general I want to resist seeing the type stubs as yet another form of docs. It should serve one need: to provide stubs usable by automatic type checkers. Also the majority of these are redundant, e.g. month: MonthType
repeated over and over (in fact MonthType
is less helpful than int
!).
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.
De gustibus non est disputandum... I found them useful, but I am happy to remove them to adhere to the project's goals.
Good point. I've removed mention to the internal variables. |
Thanks! All good now. |
Issue 88: Stub for calendar module
Allay fears about idiomatic python becoming far more verbose
I created the stub using
make_stub_files.py
and then edited the types by hand.I ran into an issue with
mypy
: it complains that True and False are not defined. Therefore, I had to define them in the stub.Also,
python runtests.py
shows lots of errors: I don't know if this is expected.