Skip to content

Fixed type:ignore type-arg to type-var in io.common.py #15

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

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions pandas/core/dtypes/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2131,10 +2131,10 @@ def _get_common_dtype(self, dtypes: list[DtypeObj]) -> DtypeObj | None:
stacklevel=find_stack_level(),
)
np_dtypes = (x.subtype if isinstance(x, SparseDtype) else x for x in dtypes)
# error: Argument 1 to "np_find_common_type" has incompatible type
# "*Generator[Any | dtype[Any] | ExtensionDtype, None, None]";
# error: Argument 1 to "np_find_common_type" has incompatible type
# "*Generator[Any | dtype[Any] | ExtensionDtype, None, None]";
# expected "dtype[Any]" [arg-type]
return SparseDtype(np_find_common_type(*np_dtypes), fill_value=fill_value) # type: ignore [arg-type]
return SparseDtype(np_find_common_type(*np_dtypes), fill_value=fill_value) # type: ignore [arg-type]


@register_extension_dtype
Expand Down
4 changes: 3 additions & 1 deletion pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,9 @@ def __setitem__(self, key, value) -> None:
indexer = self._get_setitem_indexer(key)
self._has_valid_setitem_indexer(key)

iloc = self if self.name == "iloc" else self.obj.iloc
iloc: _iLocIndexer = (
cast("_iLocIndexer", self) if self.name == "iloc" else self.obj.iloc
)
iloc._setitem_with_indexer(indexer, value, self.name)

def _validate_key(self, key, axis: AxisInt) -> None:
Expand Down
4 changes: 3 additions & 1 deletion pandas/core/nanops.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,9 @@ def nanmean(


@bottleneck_switch()
def nanmedian(values: np.ndarray, *, axis: AxisInt | None = None, skipna: bool = True, mask=None) -> float | np.ndarray:
def nanmedian(
values: np.ndarray, *, axis: AxisInt | None = None, skipna: bool = True, mask=None
) -> float | np.ndarray:
"""
Parameters
----------
Expand Down
6 changes: 4 additions & 2 deletions pandas/io/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,12 +910,14 @@ def get_handle(
or not hasattr(handle, "seekable")
):
handle = _IOWrapper(handle)
# error: Value of type variable "_BufferT_co" of "TextIOWrapper" cannot
# be "_IOWrapper | BaseBuffer" [type-var]
handle = TextIOWrapper(
handle,
handle, # type: ignore[type-var]
encoding=ioargs.encoding,
errors=errors,
newline="",
)
) # type: ignore[arg-type]
handles.append(handle)
# only marked as wrapped when the caller provided a handle
is_wrapped = not (
Expand Down
4 changes: 2 additions & 2 deletions pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1038,9 +1038,9 @@ def __call__(self, *args, **kwargs):
label_name = label_kw or y
data.name = label_name
else:
# error: Argument 1 to "len" has incompatible type "Any | bool";
# error: Argument 1 to "len" has incompatible type "Any | bool";
# expected "Sized" [arg-type]
match = is_list_like(label_kw) and len(label_kw) == len(y) # type: ignore[arg-type]
match = is_list_like(label_kw) and len(label_kw) == len(y) # type: ignore[arg-type]
if label_kw and not match:
raise ValueError(
"label should be list-like and same length as y"
Expand Down
9 changes: 6 additions & 3 deletions pandas/tests/io/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,17 @@ def types_table_metadata(dialect: str):
"types",
metadata,
Column("TextCol", TEXT),
Column("DateCol", date_type),
# error: Cannot infer type argument 1 of "Column"
Column("DateCol", date_type), # type: ignore[misc]
Column("IntDateCol", Integer),
Column("IntDateOnlyCol", Integer),
Column("FloatCol", Float),
Column("IntCol", Integer),
Column("BoolCol", bool_type),
# error: Cannot infer type argument 1 of "Column"
Column("BoolCol", bool_type), # type: ignore[misc]
Column("IntColWithNull", Integer),
Column("BoolColWithNull", bool_type),
# error: Cannot infer type argument 1 of "Column"
Column("BoolColWithNull", bool_type), # type: ignore[misc]
)
return types

Expand Down