Skip to content
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/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,7 @@ def searchsorted(
_diff_special = {"float64", "float32", "int64", "int32", "int16", "int8"}


def diff(arr, n: int | float | np.integer, axis: AxisInt = 0):
def diff(arr, n: int | float | np.integer | np.floating, axis: AxisInt = 0):
"""
difference of n between self,
analogous to s-s.shift(n)
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/masked.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ def _hasna(self) -> bool:
# make this faster by having an optional mask, but not have to change
# source code using it..

return cast(bool, self._mask.any())
return bool(self._mask.any())
Copy link
Member

Choose a reason for hiding this comment

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

This looks good, just noting that the implementations for other _hasna already have this bool(...) where appropriate.


def _propagate_mask(
self, mask: npt.NDArray[np.bool_] | None, other
Expand Down
17 changes: 11 additions & 6 deletions pandas/io/parsers/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
Self,
TypedDict,
Unpack,
cast,
overload,
)
import warnings
Expand Down Expand Up @@ -1818,7 +1819,7 @@ def _refine_defaults_read(
return kwds


def _extract_dialect(kwds: dict[str, Any]) -> csv.Dialect | None:
def _extract_dialect(kwds: dict[str, str | csv.Dialect]) -> csv.Dialect | None:
"""
Extract concrete csv dialect instance.

Expand All @@ -1830,12 +1831,16 @@ def _extract_dialect(kwds: dict[str, Any]) -> csv.Dialect | None:
return None

dialect = kwds["dialect"]
if dialect in csv.list_dialects():
dialect = csv.get_dialect(dialect)
if isinstance(dialect, str) and dialect in csv.list_dialects():
# get_dialect is typed to return a `_csv.Dialect` for some reason in typeshed
tdialect = cast(csv.Dialect, csv.get_dialect(dialect))
_validate_dialect(tdialect)

_validate_dialect(dialect)
else:
_validate_dialect(dialect)
tdialect = cast(csv.Dialect, dialect)

return dialect # pyright: ignore[reportReturnType]
return tdialect


MANDATORY_DIALECT_ATTRS = (
Expand All @@ -1848,7 +1853,7 @@ def _extract_dialect(kwds: dict[str, Any]) -> csv.Dialect | None:
)


def _validate_dialect(dialect: csv.Dialect | Any) -> None:
def _validate_dialect(dialect: csv.Dialect | str) -> None:
"""
Validate csv dialect instance.

Expand Down
3 changes: 1 addition & 2 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@
AxisInt,
DtypeArg,
FilePath,
Shape,
npt,
)

Expand Down Expand Up @@ -3384,7 +3383,7 @@ class BlockManagerFixed(GenericFixed):
nblocks: int

@property
def shape(self) -> Shape | list[int] | None:
def shape(self) -> list[int] | None:
try:
ndim = self.ndim

Expand Down
Loading