Skip to content

Commit

Permalink
Fix ast warnings for Python3.12 (#15558)
Browse files Browse the repository at this point in the history
Warnings before:
#15330 (comment)
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>
  • Loading branch information
sobolevn and pre-commit-ci[bot] committed Jul 3, 2023
1 parent 259c822 commit a759c49
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions mypy/fastparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -1873,15 +1873,14 @@ 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:
# None is a 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)
Expand Down

0 comments on commit a759c49

Please sign in to comment.