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: I1820466231a8fd3e46b5ec8fcf2138ccd8c73ede
This commit is contained in:
Cyril Roelandt 2024-07-23 16:56:08 +02:00
parent 7a45064547
commit 85e56595d3

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]