From a759c490d21bb9d73e788da4a8dc5c10b077a482 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Mon, 3 Jul 2023 20:05:49 +0300 Subject: [PATCH] Fix `ast` warnings for Python3.12 (#15558) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Warnings before: https://github.com/python/mypy/issues/15330#issuecomment-1615010604 Warnings after: ``` (.venv312) ~/Desktop/mypy master ✗ » python -m mypy ex.py Success: no issues found in 1 source file ``` Zero :) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- mypy/fastparse.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mypy/fastparse.py b/mypy/fastparse.py index 3f4e2f4c927d..fa185be21f9e 100644 --- a/mypy/fastparse.py +++ b/mypy/fastparse.py @@ -1873,7 +1873,6 @@ def visit_BinOp(self, n: ast3.BinOp) -> Type: uses_pep604_syntax=True, ) - # Only for 3.8 and newer def visit_Constant(self, n: Constant) -> Type: val = n.value if val is None: @@ -1881,7 +1880,7 @@ def visit_Constant(self, n: Constant) -> Type: return UnboundType("None", line=self.line) if isinstance(val, str): # Parse forward reference. - return parse_type_string(n.s, "builtins.str", self.line, n.col_offset) + return parse_type_string(val, "builtins.str", self.line, n.col_offset) if val is Ellipsis: # '...' is valid in some types. return EllipsisType(line=self.line)