Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated sphinx.pycode.ast.parse() #11371

Merged
merged 3 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Incompatible changes
* #11366: Make ``locale`` a required argument to
``sphinx.util.i18n.format_date()``.
* #11370: Remove deprecated ``sphinx.util.stemmer`` module.
* #11371: Remove deprecated ``sphinx.pycode.ast.parse()`` function.

Deprecated
----------
Expand Down
17 changes: 0 additions & 17 deletions sphinx/pycode/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
from __future__ import annotations

import ast
import warnings
from typing import overload

from sphinx.deprecation import RemovedInSphinx70Warning

OPERATORS: dict[type[ast.AST], str] = {
ast.Add: "+",
ast.And: "and",
Expand All @@ -31,20 +28,6 @@
}


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:
# Some syntax error found. To ignore invalid type comments, retry parsing without
# type_comments parameter (refs: https://github.com/sphinx-doc/sphinx/issues/8652).
return ast.parse(code, mode=mode)


@overload
def unparse(node: None, code: str = '') -> None:
...
Expand Down