Skip to content
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

Upgrade mypy to 0.940 #1466

Merged
merged 5 commits into from
Mar 12, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ repos:
]
exclude: tests/testdata|conf.py
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.931
rev: v0.940
hooks:
- id: mypy
name: mypy
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_pre_commit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ pylint==2.12.2
isort==5.10.1
flake8==4.0.1
flake8-typing-imports==1.12.0
mypy==0.931
mypy==0.940
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ scripts_are_modules = True
no_implicit_optional = True
warn_redundant_casts = True
show_error_codes = True
enable_error_code = ignore-without-code

[mypy-setuptools]
ignore_missing_imports = True
Expand Down
6 changes: 3 additions & 3 deletions tests/unittest_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ def test_type_comments_with() -> None:
"""
with a as b: # type: int
pass
with a as b: # type: ignore
with a as b: # type: ignore[name-defined]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't saw that those these here are inside code blocks 😅
Doesn't matter now I guess.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's interesting that mypy picks up on those. Do you know if code in code blocks is checked? If not, this option also probably shouldn't?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's interesting that mypy picks up on those. Do you know if code in code blocks is checked? If not, this option also probably shouldn't?

Mypy didn't notice those. I just searched for type: ignore and looked which ones didn't have error codes 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm not mistaken they did. I think I saw an error message about not having the error specified for these.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm 🤔 I just removed the comment and ran mypy. Didn't saw it.
Under the hood mypy uses ast parsing and this would be just one string node. So hard to imagine that it would mark it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably my memory messing up 😅

pass
"""
)
Expand All @@ -1239,7 +1239,7 @@ def test_type_comments_for() -> None:
"""
for a, b in [1, 2, 3]: # type: List[int]
pass
for a, b in [1, 2, 3]: # type: ignore
for a, b in [1, 2, 3]: # type: ignore[name-defined]
pass
"""
)
Expand All @@ -1256,7 +1256,7 @@ def test_type_coments_assign() -> None:
module = builder.parse(
"""
a, b = [1, 2, 3] # type: List[int]
a, b = [1, 2, 3] # type: ignore
a, b = [1, 2, 3] # type: ignore[name-defined]
"""
)
node = module.body[0]
Expand Down
8 changes: 4 additions & 4 deletions tests/unittest_nodes_lineno.py
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ def test_end_lineno_comprehension() -> None:
c1 = ast_nodes[0]
assert isinstance(c1, nodes.ListComp)
assert isinstance(c1.elt, nodes.Name)
assert isinstance(c1.generators[0], nodes.Comprehension) # type: ignore
assert isinstance(c1.generators[0], nodes.Comprehension) # type: ignore[index]
cdce8p marked this conversation as resolved.
Show resolved Hide resolved
assert (c1.lineno, c1.col_offset) == (1, 0)
assert (c1.end_lineno, c1.end_col_offset) == (1, 16)
assert (c1.elt.lineno, c1.elt.col_offset) == (1, 1)
Expand All @@ -1162,7 +1162,7 @@ def test_end_lineno_comprehension() -> None:
c2 = ast_nodes[1]
assert isinstance(c2, nodes.SetComp)
assert isinstance(c2.elt, nodes.Name)
assert isinstance(c2.generators[0], nodes.Comprehension) # type: ignore
assert isinstance(c2.generators[0], nodes.Comprehension) # type: ignore[index]
assert (c2.lineno, c2.col_offset) == (2, 0)
assert (c2.end_lineno, c2.end_col_offset) == (2, 16)
assert (c2.elt.lineno, c2.elt.col_offset) == (2, 1)
Expand All @@ -1172,7 +1172,7 @@ def test_end_lineno_comprehension() -> None:
assert isinstance(c3, nodes.DictComp)
assert isinstance(c3.key, nodes.Name)
assert isinstance(c3.value, nodes.Name)
assert isinstance(c3.generators[0], nodes.Comprehension) # type: ignore
assert isinstance(c3.generators[0], nodes.Comprehension) # type: ignore[index]
assert (c3.lineno, c3.col_offset) == (3, 0)
assert (c3.end_lineno, c3.end_col_offset) == (3, 22)
assert (c3.key.lineno, c3.key.col_offset) == (3, 1)
Expand All @@ -1183,7 +1183,7 @@ def test_end_lineno_comprehension() -> None:
c4 = ast_nodes[3]
assert isinstance(c4, nodes.GeneratorExp)
assert isinstance(c4.elt, nodes.Name)
assert isinstance(c4.generators[0], nodes.Comprehension) # type: ignore
assert isinstance(c4.generators[0], nodes.Comprehension) # type: ignore[index]
assert (c4.lineno, c4.col_offset) == (4, 0)
assert (c4.end_lineno, c4.end_col_offset) == (4, 16)
assert (c4.elt.lineno, c4.elt.col_offset) == (4, 1)
Expand Down