From b74f634d9461bc0b849aae3d22950b0cd422e9b9 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Fri, 28 Oct 2022 10:54:29 -0700 Subject: [PATCH] typed-ast: fix get_docstring, allow buffer --- stubs/typed-ast/typed_ast/ast27.pyi | 5 +++-- stubs/typed-ast/typed_ast/ast3.pyi | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/stubs/typed-ast/typed_ast/ast27.pyi b/stubs/typed-ast/typed_ast/ast27.pyi index 4faf50e6683f..ff3ccdcc86d8 100644 --- a/stubs/typed-ast/typed_ast/ast27.pyi +++ b/stubs/typed-ast/typed_ast/ast27.pyi @@ -1,3 +1,4 @@ +from _typeshed import ReadableBuffer from collections.abc import Iterator from typing import Any from typing_extensions import TypeAlias @@ -9,11 +10,11 @@ class NodeVisitor: class NodeTransformer(NodeVisitor): def generic_visit(self, node: AST) -> None: ... -def parse(source: str | bytes, filename: str | bytes = ..., mode: str = ...) -> AST: ... +def parse(source: str | ReadableBuffer, filename: str | ReadableBuffer = ..., mode: str = ...) -> AST: ... def copy_location(new_node: AST, old_node: AST) -> AST: ... def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ... def fix_missing_locations(node: AST) -> AST: ... -def get_docstring(node: AST, clean: bool = ...) -> bytes | None: ... +def get_docstring(node: AST, clean: bool = ...) -> str | bytes | None: ... def increment_lineno(node: AST, n: int = ...) -> AST: ... def iter_child_nodes(node: AST) -> Iterator[AST]: ... def iter_fields(node: AST) -> Iterator[tuple[str, Any]]: ... diff --git a/stubs/typed-ast/typed_ast/ast3.pyi b/stubs/typed-ast/typed_ast/ast3.pyi index 1acf9315ba0c..230a6ac99b03 100644 --- a/stubs/typed-ast/typed_ast/ast3.pyi +++ b/stubs/typed-ast/typed_ast/ast3.pyi @@ -1,3 +1,4 @@ +from _typeshed import ReadableBuffer from collections.abc import Iterator from typing import Any from typing_extensions import TypeAlias @@ -9,7 +10,9 @@ class NodeVisitor: class NodeTransformer(NodeVisitor): def generic_visit(self, node: AST) -> None: ... -def parse(source: str | bytes, filename: str | bytes = ..., mode: str = ..., feature_version: int = ...) -> AST: ... +def parse( + source: str | ReadableBuffer, filename: str | ReadableBuffer = ..., mode: str = ..., feature_version: int = ... +) -> AST: ... def copy_location(new_node: AST, old_node: AST) -> AST: ... def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ... def fix_missing_locations(node: AST) -> AST: ...