Skip to content

Commit 324b986

Browse files
TYP: Enable mypy stricter typing for partial types (#62349)
1 parent e503c13 commit 324b986

File tree

7 files changed

+15
-12
lines changed

7 files changed

+15
-12
lines changed

pandas/core/arrays/timedeltas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def dtype(self) -> np.dtype[np.timedelta64]: # type: ignore[override]
202202
# ----------------------------------------------------------------
203203
# Constructors
204204

205-
_freq = None
205+
_freq: Tick | Day | None = None
206206

207207
@classmethod
208208
def _validate_dtype(cls, values, dtype):

pandas/core/dtypes/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
INT64_DTYPE = np.dtype(np.int64)
7070

7171
# oh the troubles to reduce import time
72-
_is_scipy_sparse = None
72+
_is_scipy_sparse: Callable[[ArrayLike], bool] | None = None
7373

7474
ensure_float64 = algos.ensure_float64
7575
ensure_int64 = algos.ensure_int64

pandas/core/indexes/base.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ def _engine_type(
470470

471471
str = Accessor("str", StringMethods)
472472

473-
_references = None
473+
_references: BlockValuesRefs | None = None
474474

475475
# --------------------------------------------------------------------
476476
# Constructors
@@ -640,7 +640,10 @@ def _dtype_to_subclass(cls, dtype: DtypeObj):
640640

641641
@classmethod
642642
def _simple_new(
643-
cls, values: ArrayLike, name: Hashable | None = None, refs=None
643+
cls,
644+
values: ArrayLike,
645+
name: Hashable | None = None,
646+
refs: BlockValuesRefs | None = None,
644647
) -> Self:
645648
"""
646649
We require that we have a dtype compat for the values. If we are passed

pandas/io/excel/_base.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,9 +1181,6 @@ def __new__(
11811181

11821182
return object.__new__(cls)
11831183

1184-
# declare external properties you can count on
1185-
_path = None
1186-
11871184
@property
11881185
def supported_extensions(self) -> tuple[str, ...]:
11891186
"""Extensions that writer engine supports."""

pandas/io/pytables.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@
114114
Iterator,
115115
Sequence,
116116
)
117-
from types import TracebackType
117+
from types import (
118+
ModuleType,
119+
TracebackType,
120+
)
118121

119122
from tables import (
120123
Col,
@@ -227,7 +230,7 @@ def _ensure_term(where, scope_level: int):
227230
)
228231

229232
# oh the troubles to reduce import time
230-
_table_mod = None
233+
_table_mod: ModuleType | None = None
231234
_table_file_open_policy_is_strict = False
232235

233236

pandas/plotting/_matplotlib/converter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@
6363
from pandas._libs.tslibs.offsets import BaseOffset
6464

6565

66-
_mpl_units = {} # Cache for units overwritten by us
66+
_mpl_units: dict = {} # Cache for units overwritten by us
6767

6868

69-
def get_pairs():
69+
def get_pairs() -> list[tuple[type, type[mdates.DateConverter]]]:
7070
pairs = [
7171
(Timestamp, DatetimeConverter),
7272
(Period, PeriodConverter),

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ enable_error_code = "ignore-without-code"
534534
# Miscellaneous strictness flags
535535
allow_untyped_globals = false
536536
allow_redefinition = false
537-
local_partial_types = false
537+
local_partial_types = true
538538
implicit_reexport = true
539539
strict_equality = true
540540
# Configuring error messages

0 commit comments

Comments
 (0)