Python 3.14: do not use deprecated ast.Str

ast.Str has been deprecated since Python 3.8, and will be removed in
Python 3.14.

Change-Id: I5909ad0222e1ce388ec7593fadbb04cb5e4a0ae3
This commit is contained in:
Cyril Roelandt 2024-07-23 16:53:08 +02:00
parent 4e7a4e5414
commit 06cd8ce716

View File

@ -113,16 +113,16 @@ class FuncMockArgsDecoratorsChecker(ast.NodeVisitor):
("%s.something" % GVAL) or (GVAL + ".something")
"""
val = None
if isinstance(node, ast.Str):
if isinstance(node, ast.Constant):
val = node.s
elif isinstance(node, ast.BinOp):
if pairwise_isinstance(
(node.op, ast.Mod), (node.left, ast.Str),
(node.op, ast.Mod), (node.left, ast.Constant),
(node.right, ast.Name)):
val = node.left.s % self.globals_[node.right.id]
elif pairwise_isinstance(
(node.op, ast.Add), (node.left, ast.Name),
(node.right, ast.Str)):
(node.right, ast.Constant)):
val = self.globals_[node.left.id] + node.right.s
elif isinstance(node, ast.Name):
val = self.globals_[node.id]