From adce126949623da2f310e6ea3f9f83c37972582a Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Langa?= Date: Mon, 28 Oct 2019 17:35:33 +0100 Subject: [PATCH 1/1] Remove unnecessary casts after pinning Mypy to >= 0.740 --- Pipfile | 2 +- black.py | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Pipfile b/Pipfile index 91054fd..3784810 100644 --- a/Pipfile +++ b/Pipfile @@ -22,7 +22,7 @@ docutils = "==0.15" # not a direct dependency, see https://github.com/pypa/pipe flake8 = "*" flake8-bugbear = "*" flake8-mypy = "*" -mypy = ">=0.620" +mypy = ">=0.740" readme_renderer = "*" recommonmark = "*" Sphinx = "*" diff --git a/black.py b/black.py index 953d532..b3699d5 100644 --- a/black.py +++ b/black.py @@ -3669,14 +3669,12 @@ def _fixup_ast_constants( node: Union[ast.AST, ast3.AST, ast27.AST] ) -> Union[ast.AST, ast3.AST, ast27.AST]: """Map ast nodes deprecated in 3.8 to Constant.""" - # casts are required until this is released: - # https://github.com/python/typeshed/pull/3142 if isinstance(node, (ast.Str, ast3.Str, ast27.Str, ast.Bytes, ast3.Bytes)): - return cast(ast.AST, ast.Constant(value=node.s)) - elif isinstance(node, (ast.Num, ast3.Num, ast27.Num)): - return cast(ast.AST, ast.Constant(value=node.n)) - elif isinstance(node, (ast.NameConstant, ast3.NameConstant)): - return cast(ast.AST, ast.Constant(value=node.value)) + return ast.Constant(value=node.s) + if isinstance(node, (ast.Num, ast3.Num, ast27.Num)): + return ast.Constant(value=node.n) + if isinstance(node, (ast.NameConstant, ast3.NameConstant)): + return ast.Constant(value=node.value) return node -- 2.39.5