diff --git a/doc/source/whatsnew/v2.1.0.rst b/doc/source/whatsnew/v2.1.0.rst index 38161a29a9ff7..a037e50593737 100644 --- a/doc/source/whatsnew/v2.1.0.rst +++ b/doc/source/whatsnew/v2.1.0.rst @@ -123,7 +123,7 @@ If installed, we now require: +-----------------+-----------------+----------+---------+ | Package | Minimum Version | Required | Changed | +=================+=================+==========+=========+ -| | | X | X | +| mypy (dev) | 1.2 | | X | +-----------------+-----------------+----------+---------+ For `optional libraries `_ the general recommendation is to use the latest version. diff --git a/environment.yml b/environment.yml index 5aa1fad2e51c7..e2edf967ed8b7 100644 --- a/environment.yml +++ b/environment.yml @@ -77,7 +77,7 @@ dependencies: - cpplint - flake8=6.0.0 - isort>=5.2.1 # check that imports are in the right order - - mypy=1.0 + - mypy=1.2 - pre-commit>=2.15.0 - pyupgrade - ruff=0.0.215 diff --git a/pandas/_libs/tslibs/timestamps.pyi b/pandas/_libs/tslibs/timestamps.pyi index d8112dbaf4b48..2438daf3e1865 100644 --- a/pandas/_libs/tslibs/timestamps.pyi +++ b/pandas/_libs/tslibs/timestamps.pyi @@ -131,8 +131,12 @@ class Timestamp(datetime): def astimezone(self, tz: _tzinfo | None) -> Self: ... # type: ignore[override] def ctime(self) -> str: ... def isoformat(self, sep: str = ..., timespec: str = ...) -> str: ... + # Return type "datetime" of "strptime" incompatible with return type "Timestamp" + # in supertype "datetime" @classmethod - def strptime(cls, date_string: str, format: str) -> datetime: ... + def strptime( # type: ignore[override] + cls, date_string: str, format: str + ) -> datetime: ... def utcoffset(self) -> timedelta | None: ... def tzname(self) -> str | None: ... def dst(self) -> timedelta | None: ... diff --git a/pandas/core/arrays/masked.py b/pandas/core/arrays/masked.py index 5654fdb82dac5..576a75de9962c 100644 --- a/pandas/core/arrays/masked.py +++ b/pandas/core/arrays/masked.py @@ -950,9 +950,7 @@ def factorize( if na_index == 0: na_code = np.intp(0) else: - # mypy error: Slice index must be an integer or None - # https://github.com/python/mypy/issues/2410 - na_code = codes[:na_index].max() + 1 # type: ignore[misc] + na_code = codes[:na_index].max() + 1 codes[codes >= na_code] += 1 codes[codes == -1] = na_code # dummy value for uniques; not used since uniques_mask will be True diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 3b03532a7bee5..2f9e2e55cea4a 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -4120,7 +4120,7 @@ class animal locomotion if not drop_level: if lib.is_integer(loc): # Slice index must be an integer or None - new_index = index[loc : loc + 1] # type: ignore[misc] + new_index = index[loc : loc + 1] else: new_index = index[loc] else: diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index 4bacef71bf94c..4de67f81dcfe0 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -2942,7 +2942,7 @@ def get_loc_level(self, key, level: IndexLabel = 0, drop_level: bool = True): if not drop_level: if lib.is_integer(loc): # Slice index must be an integer or None - mi = self[loc : loc + 1] # type: ignore[misc] + mi = self[loc : loc + 1] else: mi = self[loc] return loc, mi diff --git a/requirements-dev.txt b/requirements-dev.txt index f3c9649a5a707..2dadaee4a71e0 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -54,7 +54,7 @@ black==23.1.0 cpplint flake8==6.0.0 isort>=5.2.1 -mypy==1.0 +mypy==1.2 pre-commit>=2.15.0 pyupgrade ruff==0.0.215