diff options
author | Adam Turner <9087854+AA-Turner@users.noreply.github.com> | 2022-04-19 00:10:02 +0100 |
---|---|---|
committer | Adam Turner <9087854+aa-turner@users.noreply.github.com> | 2022-10-17 15:22:06 +0100 |
commit | b277abcb49d2c6d248518ea30a179cb52175d600 (patch) | |
tree | 59e64240d7e2e799728e0c8eeb93ae4509f396e3 /sphinx/pycode/ast.py | |
parent | eb6e137097ba7db3a4dd442855512b159bd2d4bb (diff) | |
download | sphinx-git-b277abcb49d2c6d248518ea30a179cb52175d600.tar.gz |
Use ``ast.parse`` from the standard library
Diffstat (limited to 'sphinx/pycode/ast.py')
-rw-r--r-- | sphinx/pycode/ast.py | 7 |
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: |