Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fixast warnings for Python3.12#15558

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
sobolevn merged 9 commits intomasterfromissue-15330
Jul 3, 2023
Merged
Changes from1 commit
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
NextNext commit
Fixast warnings for Python3.12
  • Loading branch information
@sobolevn
sobolevn committedJun 30, 2023
commit329a3100e9d5c9c5d64009579fb2fce462e09204
19 changes: 10 additions & 9 deletionsmypy/fastparse.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -130,22 +130,16 @@
assert (
"kind" in ast3.Constant._fields
), f"This 3.8.0 alpha ({sys.version.split()[0]}) is too old; 3.8.0a3 required"
# TODO: Num, Str, Bytes, NameConstant, Ellipsis are deprecated in 3.8.
# TODO: Index, ExtSlice are deprecated in 3.9.
from ast import (
AST,
Attribute,
Bytes,
Call,
Ellipsis as ast3_Ellipsis,
Expression as ast3_Expression,
FunctionType,
Index,
Name,
NameConstant,
Num,
Starred,
Str,
UnaryOp,
USub,
)
Expand All@@ -163,6 +157,13 @@ def ast3_parse(

NamedExpr = ast3.NamedExpr
Constant = ast3.Constant
# TODO: We can delete these aliases after Python3.7 support is dropped.
# Right now, they are only needed to have the same global names as 3.7
Num = Any
Str = Any
Bytes = Any
NameConstant = Any
ast3_Ellipsis = Any
else:
from typed_ast import ast3
from typed_ast.ast3 import (
Expand DownExpand Up@@ -1580,7 +1581,7 @@ def visit_Constant(self, n: Constant) -> Any:
if val is None:
e = NameExpr("None")
elif isinstance(val, str):
e = StrExpr(n.s)
e = StrExpr(val)
elif isinstance(val, bytes):
e = BytesExpr(bytes_to_human_readable_repr(n.s))
elif isinstance(val, bool): # Must check before int!
Expand All@@ -1598,7 +1599,7 @@ def visit_Constant(self, n: Constant) -> Any:
return self.set_line(e, n)

# Num(object n) -- a number as a PyObject.
def visit_Num(self, n:ast3.Num) -> IntExpr | FloatExpr | ComplexExpr:
def visit_Num(self, n: Num) -> IntExpr | FloatExpr | ComplexExpr:
# The n field has the type complex, but complex isn't *really*
# a parent of int and float, and this causes isinstance below
# to think that the complex branch is always picked. Avoid
Expand DownExpand Up@@ -1655,7 +1656,7 @@ def visit_FormattedValue(self, n: ast3.FormattedValue) -> Expression:
return self.set_line(result_expression, n)

# Bytes(bytes s)
def visit_Bytes(self, n:ast3.Bytes) -> BytesExpr | StrExpr:
def visit_Bytes(self, n: Bytes) -> BytesExpr | StrExpr:
e = BytesExpr(bytes_to_human_readable_repr(n.s))
return self.set_line(e, n)

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp