diff --git a/.github/workflows/code-checks.yml b/.github/workflows/code-checks.yml index d4a2bedcfba1a..7d24b26f5538b 100644 --- a/.github/workflows/code-checks.yml +++ b/.github/workflows/code-checks.yml @@ -74,7 +74,7 @@ jobs: - name: Install pyright # note: keep version in sync with .pre-commit-config.yaml - run: npm install -g pyright@1.1.245 + run: npm install -g pyright@1.1.247 - name: Build Pandas id: build diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fac09fcf70511..9469a34c8aacd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -89,7 +89,7 @@ repos: types: [python] stages: [manual] # note: keep version in sync with .github/workflows/code-checks.yml - additional_dependencies: ['pyright@1.1.245'] + additional_dependencies: ['pyright@1.1.247'] - repo: local hooks: - id: flake8-rst diff --git a/doc/source/whatsnew/v1.5.0.rst b/doc/source/whatsnew/v1.5.0.rst index 9f1c4755bc54f..128fd68674f96 100644 --- a/doc/source/whatsnew/v1.5.0.rst +++ b/doc/source/whatsnew/v1.5.0.rst @@ -360,7 +360,7 @@ If installed, we now require: +-----------------+-----------------+----------+---------+ | Package | Minimum Version | Required | Changed | +=================+=================+==========+=========+ -| mypy (dev) | 0.941 | | X | +| mypy (dev) | 0.950 | | X | +-----------------+-----------------+----------+---------+ diff --git a/environment.yml b/environment.yml index dc3cba3be2132..b4710e252384c 100644 --- a/environment.yml +++ b/environment.yml @@ -24,7 +24,7 @@ dependencies: - flake8-bugbear=21.3.2 # used by flake8, find likely bugs - flake8-comprehensions=3.7.0 # used by flake8, linting of unnecessary comprehensions - isort>=5.2.1 # check that imports are in the right order - - mypy=0.941 + - mypy=0.950 - pre-commit>=2.9.2 - pycodestyle # used by flake8 - pyupgrade diff --git a/pandas/_config/localization.py b/pandas/_config/localization.py index 2a487fa4b6877..2e1ef31033d71 100644 --- a/pandas/_config/localization.py +++ b/pandas/_config/localization.py @@ -45,7 +45,9 @@ def set_locale( locale.setlocale(lc_var, new_locale) normalized_locale = locale.getlocale() if all(x is not None for x in normalized_locale): - yield ".".join(normalized_locale) + # error: Argument 1 to "join" of "str" has incompatible type + # "Tuple[Optional[str], Optional[str]]"; expected "Iterable[str]" + yield ".".join(normalized_locale) # type: ignore[arg-type] else: yield new_locale finally: diff --git a/pandas/_libs/tslibs/timestamps.pyi b/pandas/_libs/tslibs/timestamps.pyi index 13daba5cfcbdf..4be9621a594dc 100644 --- a/pandas/_libs/tslibs/timestamps.pyi +++ b/pandas/_libs/tslibs/timestamps.pyi @@ -113,7 +113,7 @@ class Timestamp(datetime): def time(self) -> _time: ... def timetz(self) -> _time: ... def replace( - self, + self: _DatetimeT, year: int = ..., month: int = ..., day: int = ..., @@ -123,7 +123,7 @@ class Timestamp(datetime): microsecond: int = ..., tzinfo: _tzinfo | None = ..., fold: int = ..., - ) -> datetime: ... + ) -> _DatetimeT: ... def astimezone(self: _DatetimeT, tz: _tzinfo | None = ...) -> _DatetimeT: ... def ctime(self) -> str: ... def isoformat(self, sep: str = ..., timespec: str = ...) -> str: ... diff --git a/pandas/core/arrays/masked.py b/pandas/core/arrays/masked.py index a7bb9520841b6..3616e3512c6fe 100644 --- a/pandas/core/arrays/masked.py +++ b/pandas/core/arrays/masked.py @@ -957,7 +957,7 @@ def equals(self, other) -> bool: return array_equivalent(left, right, dtype_equal=True) def _quantile( - self: BaseMaskedArrayT, qs: npt.NDArray[np.float64], interpolation: str + self, qs: npt.NDArray[np.float64], interpolation: str ) -> BaseMaskedArray: """ Dispatch to quantile_with_mask, needed because we do not have diff --git a/pandas/io/parsers/base_parser.py b/pandas/io/parsers/base_parser.py index 2851ea36c8a33..97ec297db8ba8 100644 --- a/pandas/io/parsers/base_parser.py +++ b/pandas/io/parsers/base_parser.py @@ -7,6 +7,7 @@ from enum import Enum import itertools from typing import ( + Any, Callable, DefaultDict, Hashable, @@ -1027,26 +1028,14 @@ def _get_empty_meta( # Convert `dtype` to a defaultdict of some kind. # This will enable us to write `dtype[col_name]` # without worrying about KeyError issues later on. + dtype_dict: defaultdict[Hashable, Any] if not is_dict_like(dtype): # if dtype == None, default will be object. default_dtype = dtype or object - # error: Argument 1 to "defaultdict" has incompatible type "Callable[[], - # Union[ExtensionDtype, str, dtype[Any], Type[object], Dict[Hashable, - # Union[ExtensionDtype, Union[str, dtype[Any]], Type[str], Type[float], - # Type[int], Type[complex], Type[bool], Type[object]]]]]"; expected - # "Optional[Callable[[], Union[ExtensionDtype, str, dtype[Any], - # Type[object]]]]" - # error: Incompatible return value type (got "Union[ExtensionDtype, str, - # dtype[Any], Type[object], Dict[Hashable, Union[ExtensionDtype, Union[str, - # dtype[Any]], Type[str], Type[float], Type[int], Type[complex], Type[bool], - # Type[object]]]]", expected "Union[ExtensionDtype, str, dtype[Any], - # Type[object]]") - dtype = defaultdict( - lambda: default_dtype # type: ignore[arg-type, return-value] - ) + dtype_dict = defaultdict(lambda: default_dtype) else: dtype = cast(dict, dtype) - dtype = defaultdict( + dtype_dict = defaultdict( lambda: object, {columns[k] if is_integer(k) else k: v for k, v in dtype.items()}, ) @@ -1063,14 +1052,16 @@ def _get_empty_meta( if (index_col is None or index_col is False) or index_names is None: index = Index([]) else: - data = [Series([], dtype=dtype[name]) for name in index_names] + data = [Series([], dtype=dtype_dict[name]) for name in index_names] index = ensure_index_from_sequences(data, names=index_names) index_col.sort() for i, n in enumerate(index_col): columns.pop(n - i) - col_dict = {col_name: Series([], dtype=dtype[col_name]) for col_name in columns} + col_dict = { + col_name: Series([], dtype=dtype_dict[col_name]) for col_name in columns + } return index, columns, col_dict diff --git a/requirements-dev.txt b/requirements-dev.txt index a3f71ac2a3aa5..0f1d76b996df1 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -12,7 +12,7 @@ flake8==4.0.1 flake8-bugbear==21.3.2 flake8-comprehensions==3.7.0 isort>=5.2.1 -mypy==0.941 +mypy==0.950 pre-commit>=2.9.2 pycodestyle pyupgrade