Remove unnecessary casts after pinning Mypy to >= 0.740

This commit is contained in:
Łukasz Langa 2019-10-28 17:35:33 +01:00
parent 95fd5cb648
commit adce126949
No known key found for this signature in database
GPG Key ID: B26995E310250568
2 changed files with 6 additions and 8 deletions

View File

@ -22,7 +22,7 @@ docutils = "==0.15" # not a direct dependency, see https://github.com/pypa/pipe
flake8 = "*" flake8 = "*"
flake8-bugbear = "*" flake8-bugbear = "*"
flake8-mypy = "*" flake8-mypy = "*"
mypy = ">=0.620" mypy = ">=0.740"
readme_renderer = "*" readme_renderer = "*"
recommonmark = "*" recommonmark = "*"
Sphinx = "*" Sphinx = "*"

View File

@ -3669,14 +3669,12 @@ def _fixup_ast_constants(
node: Union[ast.AST, ast3.AST, ast27.AST] node: Union[ast.AST, ast3.AST, ast27.AST]
) -> Union[ast.AST, ast3.AST, ast27.AST]: ) -> Union[ast.AST, ast3.AST, ast27.AST]:
"""Map ast nodes deprecated in 3.8 to Constant.""" """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)): if isinstance(node, (ast.Str, ast3.Str, ast27.Str, ast.Bytes, ast3.Bytes)):
return cast(ast.AST, ast.Constant(value=node.s)) return ast.Constant(value=node.s)
elif isinstance(node, (ast.Num, ast3.Num, ast27.Num)): if isinstance(node, (ast.Num, ast3.Num, ast27.Num)):
return cast(ast.AST, ast.Constant(value=node.n)) return ast.Constant(value=node.n)
elif isinstance(node, (ast.NameConstant, ast3.NameConstant)): if isinstance(node, (ast.NameConstant, ast3.NameConstant)):
return cast(ast.AST, ast.Constant(value=node.value)) return ast.Constant(value=node.value)
return node return node