summaryrefslogtreecommitdiff
path: root/sphinx/pycode/ast.py
diff options
context:
space:
mode:
authorAdam Turner <9087854+AA-Turner@users.noreply.github.com>2022-04-19 00:10:02 +0100
committerAdam Turner <9087854+aa-turner@users.noreply.github.com>2022-10-17 15:22:06 +0100
commitb277abcb49d2c6d248518ea30a179cb52175d600 (patch)
tree59e64240d7e2e799728e0c8eeb93ae4509f396e3 /sphinx/pycode/ast.py
parenteb6e137097ba7db3a4dd442855512b159bd2d4bb (diff)
downloadsphinx-git-b277abcb49d2c6d248518ea30a179cb52175d600.tar.gz
Use ``ast.parse`` from the standard library
Diffstat (limited to 'sphinx/pycode/ast.py')
-rw-r--r--sphinx/pycode/ast.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/sphinx/pycode/ast.py b/sphinx/pycode/ast.py
index e61b01d18..4997ab09e 100644
--- a/sphinx/pycode/ast.py
+++ b/sphinx/pycode/ast.py
@@ -1,8 +1,11 @@
"""Helpers for AST (Abstract Syntax Tree)."""
import ast
+import warnings
from typing import Dict, List, Optional, Type, overload
+from sphinx.deprecation import RemovedInSphinx70Warning
+
OPERATORS: Dict[Type[ast.AST], str] = {
ast.Add: "+",
ast.And: "and",
@@ -28,6 +31,10 @@ OPERATORS: Dict[Type[ast.AST], str] = {
def parse(code: str, mode: str = 'exec') -> "ast.AST":
"""Parse the *code* using the built-in ast module."""
+ warnings.warn(
+ "'sphinx.pycode.ast.parse' is deprecated, use 'ast.parse' instead.",
+ RemovedInSphinx70Warning, stacklevel=2
+ )
try:
return ast.parse(code, mode=mode, type_comments=True)
except SyntaxError: