summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2021-11-17 12:56:08 +0100
committerGitHub <noreply@github.com>2021-11-17 12:56:08 +0100
commit5845f21095aeb178f92cad607817e7a407a4b539 (patch)
tree10d804c6828f414cb960ab44b51cd3e0991069c5
parent2c9c187b1c47adc4661246b922e3a41dc0756396 (diff)
downloadastroid-git-5845f21095aeb178f92cad607817e7a407a4b539.tar.gz
Add additional flags to ``mypy`` config and update ``type: ignore``'s (#1248)
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
-rw-r--r--astroid/nodes/node_ng.py2
-rw-r--r--astroid/rebuilder.py4
-rw-r--r--setup.cfg3
-rw-r--r--tests/unittest_protocols.py12
-rw-r--r--tests/unittest_regrtest.py2
5 files changed, 13 insertions, 10 deletions
diff --git a/astroid/nodes/node_ng.py b/astroid/nodes/node_ng.py
index 81fb78e2..0d19dcaa 100644
--- a/astroid/nodes/node_ng.py
+++ b/astroid/nodes/node_ng.py
@@ -502,7 +502,7 @@ class NodeNG:
) -> Iterator[T_Nodes]:
...
- def nodes_of_class( # type: ignore # mypy doesn't correctly recognize the overloads
+ def nodes_of_class( # type: ignore[misc] # mypy doesn't correctly recognize the overloads
self,
klass: Union[
Type[T_Nodes],
diff --git a/astroid/rebuilder.py b/astroid/rebuilder.py
index b67a9c94..ba4ca0a6 100644
--- a/astroid/rebuilder.py
+++ b/astroid/rebuilder.py
@@ -1215,7 +1215,7 @@ class TreeRebuilder:
) -> nodes.Tuple:
"""visit an ExtSlice node by returning a fresh instance of Tuple"""
newnode = nodes.Tuple(ctx=Context.Load, parent=parent)
- newnode.postinit([self.visit(dim, newnode) for dim in node.dims]) # type: ignore
+ newnode.postinit([self.visit(dim, newnode) for dim in node.dims]) # type: ignore[attr-defined]
return newnode
@overload
@@ -1434,7 +1434,7 @@ class TreeRebuilder:
# Not used in Python 3.9+.
def visit_index(self, node: "ast.Index", parent: nodes.Subscript) -> NodeNG:
"""visit a Index node by returning a fresh instance of NodeNG"""
- return self.visit(node.value, parent) # type: ignore
+ return self.visit(node.value, parent) # type: ignore[attr-defined]
def visit_keyword(self, node: "ast.keyword", parent: NodeNG) -> nodes.Keyword:
"""visit a Keyword node by returning a fresh instance of it"""
diff --git a/setup.cfg b/setup.cfg
index 7482c74b..61807a22 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -65,6 +65,9 @@ skip_glob = tests/testdata
[mypy]
scripts_are_modules = True
+no_implicit_optional = True
+warn_redundant_casts = True
+show_error_codes = True
[mypy-setuptools]
ignore_missing_imports = True
diff --git a/tests/unittest_protocols.py b/tests/unittest_protocols.py
index 9d8445ed..58d7f2e3 100644
--- a/tests/unittest_protocols.py
+++ b/tests/unittest_protocols.py
@@ -297,7 +297,7 @@ class TestPatternMatching:
pass
"""
)
- match_mapping: nodes.MatchMapping = assign_stmts.pattern # type: ignore
+ match_mapping: nodes.MatchMapping = assign_stmts.pattern # type: ignore[union-attr]
assert match_mapping.rest
assigned = next(match_mapping.rest.assigned_stmts())
assert assigned == Uninferable
@@ -316,7 +316,7 @@ class TestPatternMatching:
pass
"""
)
- match_sequence: nodes.MatchSequence = assign_stmts.pattern # type: ignore
+ match_sequence: nodes.MatchSequence = assign_stmts.pattern # type: ignore[union-attr]
match_star = match_sequence.patterns[2]
assert isinstance(match_star, nodes.MatchStar) and match_star.name
assigned = next(match_star.name.assigned_stmts())
@@ -337,10 +337,10 @@ class TestPatternMatching:
pass
"""
)
- subject: nodes.Const = assign_stmts[0].subject # type: ignore
- match_or: nodes.MatchOr = assign_stmts[1].pattern # type: ignore
- match_as_with_pattern: nodes.MatchAs = assign_stmts[2].pattern # type: ignore
- match_as: nodes.MatchAs = assign_stmts[3].pattern # type: ignore
+ subject: nodes.Const = assign_stmts[0].subject # type: ignore[index,union-attr]
+ match_or: nodes.MatchOr = assign_stmts[1].pattern # type: ignore[index,union-attr]
+ match_as_with_pattern: nodes.MatchAs = assign_stmts[2].pattern # type: ignore[index,union-attr]
+ match_as: nodes.MatchAs = assign_stmts[3].pattern # type: ignore[index,union-attr]
match_or_1 = match_or.patterns[1]
assert isinstance(match_or_1, nodes.MatchAs) and match_or_1.name
diff --git a/tests/unittest_regrtest.py b/tests/unittest_regrtest.py
index 35a900e7..f3300411 100644
--- a/tests/unittest_regrtest.py
+++ b/tests/unittest_regrtest.py
@@ -346,7 +346,7 @@ def test(val):
class Whatever:
- a = property(lambda x: x, lambda x: x) # type: ignore
+ a = property(lambda x: x, lambda x: x) # type: ignore[misc]
def test_ancestor_looking_up_redefined_function() -> None: