Skip to content

Commit 8babd24

Browse files
authored
Replace deprecated 'ast.Str' with 'ast.Constant' (#1083)
1 parent c382433 commit 8babd24

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

babel/messages/extract.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -640,13 +640,11 @@ def _parse_python_string(value: str, encoding: str, future_flags: int) -> str |
640640
)
641641
if isinstance(code, ast.Expression):
642642
body = code.body
643-
if isinstance(body, ast.Str):
644-
return body.s
643+
if isinstance(body, ast.Constant):
644+
return body.value
645645
if isinstance(body, ast.JoinedStr): # f-string
646-
if all(isinstance(node, ast.Str) for node in body.values):
647-
return ''.join(node.s for node in body.values)
648646
if all(isinstance(node, ast.Constant) for node in body.values):
649-
return ''.join(str(node.value) for node in body.values)
647+
return ''.join(node.value for node in body.values)
650648
# TODO: we could raise an error or warning when not all nodes are constants
651649
return None
652650

0 commit comments

Comments
 (0)