8000 typed-ast: fix get_docstring, allow buffer (#9019) · python/typeshed@7edad95 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7edad95

Browse files
authored
typed-ast: fix get_docstring, allow buffer (#9019)
1 parent 05acb6c commit 7edad95

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

stubs/typed-ast/typed_ast/ast27.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from _typeshed import ReadableBuffer
12
from collections.abc import Iterator
23
from typing import Any
34
from typing_extensions import TypeAlias
@@ -9,11 +10,11 @@ class NodeVisitor:
910
class NodeTransformer(NodeVisitor):
1011
def generic_visit(self, node: AST) -> None: ...
1112

12-
def parse(source: str | bytes, filename: str | bytes = ..., mode: str = ...) -> AST: ...
13+
def parse(source: str | ReadableBuffer, filename: str | ReadableBuffer = ..., mode: str = ...) -> AST: ...
1314
def copy_location(new_node: AST, old_node: AST) -> AST: ...
1415
def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ...
1516
def fix_missing_locations(node: AST) -> AST: ...
16-
def get_docstring(node: AST, clean: bool = ...) -> bytes | None: ...
17+
def get_docstring(node: AST, clean: bool = ...) -> str | bytes | None: ...
17 8000 18
def increment_lineno(node: AST, n: int = ...) -> AST: ...
1819
def iter_child_nodes(node: AST) -> Iterator[AST]: ...
1920
def iter_fields(node: AST) -> Iterator[tuple[str, Any]]: ...

stubs/typed-ast/typed_ast/ast3.pyi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from _typeshed import ReadableBuffer
12
from collections.abc import Iterator
23
from typing import Any
34
from typing_extensions import TypeAlias
@@ -9,7 +10,9 @@ class NodeVisitor:
910
class NodeTransformer(NodeVisitor):
1011
def generic_visit(self, node: AST) -> None: ...
1112

12-
def parse(source: str | bytes, filename: str | bytes = ..., mode: str = ..., feature_version: int = ...) -> AST: ...
13+
def parse(
14+
source: str | ReadableBuffer, filename: str | ReadableBuffer = ..., mode: str = ..., feature_version: int = ...
15+
) -> AST: ...
1316
def copy_location(new_node: AST, old_node: AST) -> AST: ...
1417
def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ...
1518
def fix_missing_locations(node: AST) -> AST: ...

0 commit comments

Comments
 (0)
0