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

Upgraded to mypy 1.5.1 #264

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 1 addition & 2 deletions icontract/_recompute.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,8 +652,7 @@ def visit_NamedExpr(self, node: ast.NamedExpr) -> Any:

self.recomputed_values[node] = value

# This assignment is needed to make mypy happy.
target = cast(ast.Name, node.target)
target = node.target

if not isinstance(target.ctx, ast.Store):
raise NotImplementedError(
Expand Down
3 changes: 1 addition & 2 deletions icontract/_represent.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ def visit_NamedExpr(self, node: ast.NamedExpr) -> Any:
if node in self._recomputed_values:
value = self._recomputed_values[node]

# This is necessary in order to make mypy happy.
target = cast(ast.Name, node.target)
target = node.target

if _representable(value=value):
self.reprs[target.id] = value
Expand Down
24 changes: 14 additions & 10 deletions precommit.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,23 @@ def main() -> int:
subprocess.check_call(
["yapf", "--diff", "--style=style.yapf", "--recursive"] + yapf_targets, cwd=str(repo_root))

print("Mypy'ing...")
mypy_targets = ["icontract", "tests"]
if sys.version_info >= (3, 6):
mypy_targets.append('tests_3_6')
if sys.version_info < (3, 8):
print("Mypy since 1.5 dropped support for Python 3.7 and "
"you are running Python {}, so skipping.".format(sys.version_info))
else:
print("Mypy'ing...")
mypy_targets = ["icontract", "tests"]
if sys.version_info >= (3, 6):
mypy_targets.append('tests_3_6')

if sys.version_info >= (3, 7):
mypy_targets.append('tests_3_7')
if sys.version_info >= (3, 7):
mypy_targets.append('tests_3_7')

if sys.version_info >= (3, 8):
mypy_targets.append('tests_3_8')
mypy_targets.append('tests_with_others')
if sys.version_info >= (3, 8):
mypy_targets.append('tests_3_8')
mypy_targets.append('tests_with_others')

subprocess.check_call(["mypy", "--strict"] + mypy_targets, cwd=str(repo_root))
subprocess.check_call(["mypy", "--strict"] + mypy_targets, cwd=str(repo_root))

print("Pylint'ing...")
pylint_targets = ['icontract', 'tests']
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@
install_requires=install_requires,
extras_require={
'dev': [
'mypy==0.991', 'pylint==2.13.9', 'yapf==0.20.2', 'tox>=3.0.0', 'pydocstyle>=6.1.1,<7', 'coverage>=4.5.1,<5',
'pylint==2.13.9', 'yapf==0.20.2', 'tox>=3.0.0', 'pydocstyle>=6.1.1,<7', 'coverage>=4.5.1,<5',
'docutils>=0.14,<1', 'pygments>=2.2.0,<3', 'dpcontracts==0.6.0', 'tabulate>=0.8.7,<1',
'py-cpuinfo>=5.0.0,<6', 'typeguard>=2,<3', 'astor==0.8.1', 'numpy>=1,<2'
] + (['deal==4.23.3'] if sys.version_info >= (3, 8) else []) + (['asyncstdlib==3.9.1']
if sys.version_info >= (3, 8) else []),
] + (['mypy==1.5.1'] if sys.version_info >= (3, 8) else []) +
(['deal==4.23.3'] if sys.version_info >= (3, 8) else []) + (['asyncstdlib==3.9.1']
if sys.version_info >= (3, 8) else []),
},
py_modules=['icontract'],
package_data={"icontract": ["py.typed"]},
Expand Down
5 changes: 5 additions & 0 deletions tests/test_mypy_decorators.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# pylint: disable=missing-docstring
import pathlib
import subprocess
import sys
import tempfile
import unittest

if sys.version_info < (3, 8):
raise unittest.SkipTest(("Mypy since 1.5 dropped support for Python 3.7 and "
"you are running Python {}, so skipping.").format(sys.version_info))


class TestMypyDecorators(unittest.TestCase):
def test_functions(self) -> None:
Expand Down
Loading