-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Adding datetimerange stubs #3845
Conversation
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.
Thank you, a few things below.
import datetime | ||
from dateutil.relativedelta import relativedelta | ||
|
||
class DateTimeRange: |
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.
Since this stub is for Python 2 as well, this should use object
as base class to mark this as a new-style class:
class DateTimeRange(object):
start_time_format: str = ... | ||
end_time_format: str = ... | ||
is_output_elapse: bool = ... | ||
separator: str = ... |
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.
Nit: = ...
is redundant.
end_time_format: str = ... | ||
is_output_elapse: bool = ... | ||
separator: str = ... | ||
def __init__(self, start_datetime: Optional[str], end_datetime: Optional[str], start_time_format: str = ..., end_time_format: str = ...) -> None: ... |
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.
start_datetime
and end_datetime
have default values, so = ...
is missing. (Optional
is unfortunately slightly misnamed and does not indicate optional arguments.)
def set_start_datetime(self, value: Union[datetime.datetime, str], timezone: str = ...) -> None: ... | ||
def set_end_datetime(self, value: Union[datetime.datetime, str], timezone: str = ...) -> None: ... |
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.
Since the timezone
arguments default to None
, they should have Optional[str]
as arguments since they obviously accept None
as well.
Thank you for that! Knew I was going to make some mistakes. I made those changes and pushed just now |
Hello I was looking to use mypy and made stubs for a library that I was using. The library in question is this one https://github.com/thombashi/DateTimeRange . This is my first PR to typeshed so lmk if I missed anything!