Support Module and other objects in ast.parse (#14837)

This commit is contained in:
GastonAQS
2025-10-06 12:04:45 -03:00
committed by GitHub
parent e9d5cc7816
commit bbe48c754c
2 changed files with 63 additions and 0 deletions
+19
View File
@@ -1744,6 +1744,16 @@ if sys.version_info < (3, 14):
_T = _TypeVar("_T", bound=AST)
if sys.version_info >= (3, 13):
@overload
def parse(
source: _T,
filename: str | ReadableBuffer | os.PathLike[Any] = "<unknown>",
mode: Literal["exec", "eval", "func_type", "single"] = "exec",
*,
type_comments: bool = False,
feature_version: None | int | tuple[int, int] = None,
optimize: Literal[-1, 0, 1, 2] = -1,
) -> _T: ...
@overload
def parse(
source: str | ReadableBuffer,
@@ -1823,6 +1833,15 @@ if sys.version_info >= (3, 13):
) -> mod: ...
else:
@overload
def parse(
source: _T,
filename: str | ReadableBuffer | os.PathLike[Any] = "<unknown>",
mode: Literal["exec", "eval", "func_type", "single"] = "exec",
*,
type_comments: bool = False,
feature_version: None | int | tuple[int, int] = None,
) -> _T: ...
@overload
def parse(
source: str | ReadableBuffer,