Skip to content

Commit 69c72f8

Browse files
committed
Use ast.literal_eval to evaluate string expression
1 parent 5c6acc4 commit 69c72f8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/griffe_warnings_deprecated/extension.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
import ast
56
from typing import Any
67

78
from griffe import Class, Docstring, DocstringSectionAdmonition, ExprCall, Extension, Function, get_logger
@@ -16,7 +17,8 @@
1617
def _deprecated(obj: Class | Function) -> str | None:
1718
for decorator in obj.decorators:
1819
if decorator.callable_path in _decorators and isinstance(decorator.value, ExprCall):
19-
return str(decorator.value.arguments[0]).lstrip("f")[1:-1]
20+
message = str(decorator.value.arguments[0]).removeprefix("f")
21+
return ast.literal_eval(message)
2022
return None
2123

2224

0 commit comments

Comments
 (0)