-
-
Notifications
You must be signed in to change notification settings - Fork 145
Add more parameter defaults #1318
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
base: main
Are you sure you want to change the base?
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.
As best as I can tell, the script you are using isn't creating default values for arguments that require a keyword, i.e., any argument that appears after an *
in the declaration. Most of my comments are about missing defaults.
periods: int | None = ..., | ||
start: str | DateAndDatetimeLike | None = None, | ||
end: str | DateAndDatetimeLike | None = None, | ||
periods: int | None = None, | ||
*, | ||
freq: str | timedelta | Timedelta | BaseOffset, | ||
tz: TimeZones = ..., |
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.
shouldn't you add defaults for the ones with ...
in them above?
periods: int | None = None, | ||
freq: str | BaseOffset | pd.Timedelta | dt.timedelta | None = None, | ||
name: Hashable = None, | ||
closed: IntervalClosedType = "right", | ||
) -> IntervalIndex[Interval[pd.Timestamp]]: ... | ||
@overload | ||
def interval_range( |
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.
Missing some defaults here
@@ -348,11 +348,11 @@ def interval_range( | |||
@overload |
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.
Missing some defaults in lines 341 to 346
periods: int | None = None, | ||
freq: str | BaseOffset | pd.Timedelta | dt.timedelta | None = None, | ||
name: Hashable = None, | ||
closed: IntervalClosedType = "right", | ||
) -> IntervalIndex[Interval[pd.Timedelta]]: ... | ||
@overload | ||
def interval_range( |
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.
missing defaults in the parameters below
fill_method: Literal["ffill"] | None = None, | ||
suffixes: Suffixes = ..., |
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.
suffixes
has a default of ("_x", "_y")
dayfirst: bool = False, | ||
yearfirst: bool = False, | ||
utc: bool = False, | ||
format: str | None = None, | ||
exact: bool = ..., |
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.
exact
defaults to True
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.
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.
Yes, but it documented as True
and that is what happens in the code.
errors: Literal["raise", "coerce"] = ..., | ||
downcast: _Downcast = ..., | ||
errors: Literal["raise", "coerce"] = "raise", | ||
downcast: _Downcast = None, | ||
dtype_backend: DtypeBackend | _NoDefaultDoNotUse = ..., |
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.
Not entirely sure whether we want to do this, but we could make the default here _NoDefaultDoNotUse
@@ -28,7 +28,7 @@ from pandas.io.parsers import TextFileReader | |||
|
|||
@overload | |||
def read_clipboard( | |||
sep: str | None = ..., | |||
sep: str | None = r"\s+", | |||
*, | |||
dtype_backend: DtypeBackend | _NoDefaultDoNotUse = ..., |
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.
the rest of the arguments to read_clipboard
have the same defaults as read_csv()
@@ -176,7 +176,7 @@ def read_excel( | |||
| OpenDocument | |||
| pyxlsb.workbook.Workbook | |||
), | |||
sheet_name: int | str = ..., | |||
sheet_name: int | str = 0, |
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.
do you want to set the defaults for the rest of the arguments to read_excel()
?
where: str | Term | Sequence[Term] | None = None, | ||
start: int | None = None, | ||
stop: int | None = None, | ||
columns: list[HashableT] | None = None, | ||
*, | ||
iterator: Literal[True], | ||
chunksize: int | 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.
chunksize
defaults to None
here and other overloads
Yup, I've excluded keyword arguments and class functions as they'd require some extra |
Yes, I think that's a good idea. |
Towards #1317
Due to improvements in https://github.com/yangdanny97/docs2types, further places with missing
| None
have emerged, I'll fix those separatelyassert_type()
to assert the type of any return value