diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index 946fda5f82279..cb97fdeccd579 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -88,7 +88,7 @@ If installed, we now require: +-----------------+-----------------+----------+---------+ | pytest (dev) | 5.0.1 | | | +-----------------+-----------------+----------+---------+ -| mypy (dev) | 0.782 | | | +| mypy (dev) | 0.790 | | X | +-----------------+-----------------+----------+---------+ For `optional libraries `_ the general recommendation is to use the latest version. diff --git a/environment.yml b/environment.yml index 600a20b153ed3..09736aeea25f2 100644 --- a/environment.yml +++ b/environment.yml @@ -23,7 +23,7 @@ dependencies: - flake8 - flake8-comprehensions>=3.1.0 # used by flake8, linting of unnecessary comprehensions - isort>=5.2.1 # check that imports are in the right order - - mypy=0.782 + - mypy=0.790 - pre-commit>=2.9.2 - pycodestyle # used by flake8 - pyupgrade diff --git a/pandas/core/computation/parsing.py b/pandas/core/computation/parsing.py index ef79c2b77e4e5..732b0650e5bd7 100644 --- a/pandas/core/computation/parsing.py +++ b/pandas/core/computation/parsing.py @@ -38,10 +38,7 @@ def create_valid_python_identifier(name: str) -> str: # token.tok_name contains a readable description of the replacement string. special_characters_replacements = { char: f"_{token.tok_name[tokval]}_" - # The ignore here is because of a bug in mypy that is resolved in 0.740 - for char, tokval in ( - tokenize.EXACT_TOKEN_TYPES.items() # type: ignore[attr-defined] - ) + for char, tokval in (tokenize.EXACT_TOKEN_TYPES.items()) } special_characters_replacements.update( { diff --git a/pandas/core/groupby/ops.py b/pandas/core/groupby/ops.py index 3262407a99c0a..62d11183691f0 100644 --- a/pandas/core/groupby/ops.py +++ b/pandas/core/groupby/ops.py @@ -283,8 +283,8 @@ def groups(self) -> Dict[Hashable, np.ndarray]: return self.groupings[0].groups else: to_groupby = zip(*(ping.grouper for ping in self.groupings)) - to_groupby = Index(to_groupby) - return self.axis.groupby(to_groupby) + index = Index(to_groupby) + return self.axis.groupby(index) @final @cache_readonly diff --git a/pandas/io/common.py b/pandas/io/common.py index 8f04724773a8a..12a886d057199 100644 --- a/pandas/io/common.py +++ b/pandas/io/common.py @@ -179,7 +179,8 @@ def stringify_path( # this function with convert_file_like=True to infer the compression. return cast(FileOrBuffer[AnyStr], filepath_or_buffer) - if isinstance(filepath_or_buffer, os.PathLike): + # Only @runtime_checkable protocols can be used with instance and class checks + if isinstance(filepath_or_buffer, os.PathLike): # type: ignore[misc] filepath_or_buffer = filepath_or_buffer.__fspath__() return _expand_user(filepath_or_buffer) @@ -487,9 +488,15 @@ def infer_compression( if compression in _compression_to_extension: return compression - msg = f"Unrecognized compression type: {compression}" - valid = ["infer", None] + sorted(_compression_to_extension) - msg += f"\nValid compression types are {valid}" + # https://github.com/python/mypy/issues/5492 + # Unsupported operand types for + ("List[Optional[str]]" and "List[str]") + valid = ["infer", None] + sorted( + _compression_to_extension + ) # type: ignore[operator] + msg = ( + f"Unrecognized compression type: {compression}\n" + f"Valid compression types are {valid}" + ) raise ValueError(msg) diff --git a/requirements-dev.txt b/requirements-dev.txt index d45e87b1785b0..80fd7b243f6ce 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -11,7 +11,7 @@ cpplint flake8 flake8-comprehensions>=3.1.0 isort>=5.2.1 -mypy==0.782 +mypy==0.790 pre-commit>=2.9.2 pycodestyle pyupgrade