-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CI: Unpin MyPy #36012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CI: Unpin MyPy #36012
Changes from all commits
be7b516
700205d
5f537a1
9d4f36b
3c11ad5
709c2fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
from datetime import datetime, timedelta | ||
from functools import partial | ||
import inspect | ||
from typing import Any, Collection, Iterable, Iterator, List, Union | ||
from typing import Any, Collection, Iterable, Iterator, List, Union, cast | ||
import warnings | ||
|
||
import numpy as np | ||
|
@@ -277,6 +277,11 @@ def maybe_iterable_to_list(obj: Union[Iterable[T], T]) -> Union[Collection[T], T | |
""" | ||
if isinstance(obj, abc.Iterable) and not isinstance(obj, abc.Sized): | ||
return list(obj) | ||
# error: Incompatible return value type (got | ||
# "Union[pandas.core.common.<subclass of "Iterable" and "Sized">, | ||
# pandas.core.common.<subclass of "Iterable" and "Sized">1, T]", expected | ||
# "Union[Collection[T], T]") [return-value] | ||
obj = cast(Collection, obj) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. our signature here is not entirely correct. If we pass an Iterable with a __len__ method which is not necessarily a collection, the object is returned unchanged. I think best to leave signature unchanged for now and could use Protocol in the future. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since i'm lying to the type checker a #type: ignore is probably more preferable to a cast. |
||
return obj | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -364,7 +364,7 @@ class BaseExprVisitor(ast.NodeVisitor): | |
|
||
unary_ops = _unary_ops_syms | ||
unary_op_nodes = "UAdd", "USub", "Invert", "Not" | ||
unary_op_nodes_map = dict(zip(unary_ops, unary_op_nodes)) | ||
unary_op_nodes_map = {k: v for k, v in zip(unary_ops, unary_op_nodes)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mypy giving error: Need type annotation for 'unary_op_nodes_map' (hint: "unary_op_nodes_map: Dict[, ] = ...") [var-annotated] mypy is ok with a dictcomp, or could add Dict[str, str] as variable type annotation instead |
||
|
||
rewrite_map = { | ||
ast.Eq: ast.In, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,5 +103,7 @@ def __str__(self) -> str: | |
def __repr__(self) -> str: | ||
return f"{type(self).__name__}({str(self)})" | ||
|
||
__setitem__ = __setslice__ = __delitem__ = __delslice__ = _disabled | ||
pop = append = extend = remove = sort = insert = _disabled | ||
__setitem__ = __setslice__ = _disabled # type: ignore[assignment] | ||
__delitem__ = __delslice__ = _disabled # type: ignore[assignment] | ||
pop = append = extend = _disabled # type: ignore[assignment] | ||
remove = sort = insert = _disabled # type: ignore[assignment] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we probably could make FrozenList Generic to allow type annotations such as FrozenList[Label] This is an exercise for another day. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,10 +127,7 @@ show_error_codes = True | |
[mypy-pandas.tests.*] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.conftest] | ||
ignore_errors=True | ||
|
||
[mypy-pandas.tests.tools.test_to_datetime] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. errors were fixed with latest typeshed |
||
[mypy-pandas.conftest,pandas.tests.window.conftest] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similar error in pandas.tests.window.conftest as in pandas.conftest,pandas, so bundled together. this is a mypy inference issue we have encountered before error: List item 0 has incompatible type "ParameterSet"; expected "Sequence[Collection[object]]" [list-item] |
||
ignore_errors=True | ||
|
||
[mypy-pandas._testing] | ||
|
@@ -139,7 +136,22 @@ check_untyped_defs=False | |
[mypy-pandas._version] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.arrays.interval] | ||
[mypy-pandas.compat.pickle_compat] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.apply] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.arrays.base] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.arrays.datetimelike] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.arrays.sparse.array] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.arrays.string_] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.base] | ||
|
@@ -151,6 +163,9 @@ check_untyped_defs=False | |
[mypy-pandas.core.computation.expressions] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.computation.ops] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.computation.pytables] | ||
check_untyped_defs=False | ||
|
||
|
@@ -163,6 +178,9 @@ check_untyped_defs=False | |
[mypy-pandas.core.generic] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.groupby.base] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.groupby.generic] | ||
check_untyped_defs=False | ||
|
||
|
@@ -172,15 +190,33 @@ check_untyped_defs=False | |
[mypy-pandas.core.groupby.ops] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.indexes.base] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.indexes.category] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.indexes.datetimelike] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.indexes.datetimes] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.indexes.extension] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.indexes.interval] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.indexes.multi] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.indexes.period] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.indexes.range] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.internals.blocks] | ||
check_untyped_defs=False | ||
|
||
|
@@ -190,15 +226,27 @@ check_untyped_defs=False | |
[mypy-pandas.core.internals.managers] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.internals.ops] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.missing] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.ops.docstrings] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.resample] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.reshape.concat] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.reshape.merge] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.series] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.core.strings] | ||
check_untyped_defs=False | ||
|
||
|
@@ -214,6 +262,9 @@ check_untyped_defs=False | |
[mypy-pandas.io.clipboard] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.io.common] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.io.excel._base] | ||
check_untyped_defs=False | ||
|
||
|
@@ -232,6 +283,9 @@ check_untyped_defs=False | |
[mypy-pandas.io.formats.css] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.io.formats.csvs] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.io.formats.excel] | ||
check_untyped_defs=False | ||
|
||
|
@@ -270,3 +324,10 @@ check_untyped_defs=False | |
|
||
[mypy-pandas.plotting._matplotlib.misc] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.plotting._misc] | ||
check_untyped_defs=False | ||
|
||
[mypy-pandas.util._decorators] | ||
check_untyped_defs=False | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
latest typeshed (bundled with mypy) exposes undocumented attributes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this mean theres a lower bound for what mypy we want?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that in general it is recommended to pin mypy see https://mypy.readthedocs.io/en/stable/existing_code.html?highlight=pin#continuous-integration
with warn_unused_ignores, yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so I could change to mypy=0.782 (best practice) or mypy>=0.782 (see #27568 (comment))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented above, prefer either of these to no version