Skip to content

TYP: Enable mypy stricter typing for defs/calls #54271

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

Merged
merged 7 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/core/interchange/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def select_columns(self, indices: Sequence[int]) -> PandasDataFrameXchg:
self._df.iloc[:, indices], self._nan_as_null, self._allow_copy
)

def select_columns_by_name(self, names: Sequence[str]) -> PandasDataFrameXchg:
def select_columns_by_name(self, names: list[str]) -> PandasDataFrameXchg: # type: ignore[override] # noqa: E501
Copy link
Contributor

Choose a reason for hiding this comment

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

This is pretty interesting that you have to do the override. In some sense, the method DataFrameXchg.select_columns_by_name() is wrong when it says names is Sequence[str], because probably the people who wrote that aren't aware that a pure str will match.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah this might be an oversight on the original spec. I opened an issue regarding this data-apis/dataframe-api#212

if not isinstance(names, abc.Sequence):
raise ValueError("`names` is not a sequence")
if not isinstance(names, list):
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/gbq.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def to_gbq(
table_schema: list[dict[str, str]] | None = None,
location: str | None = None,
progress_bar: bool = True,
credentials: Any = None,
credentials: google.auth.credentials.Credentials | None = None,
) -> None:
pandas_gbq = _try_import()
pandas_gbq.to_gbq(
Expand Down