typed-ast: fix get_docstring, allow buffer (#9019)

This commit is contained in:
Shantanu
2022-10-28 11:05:16 -07:00
committed by GitHub
parent 05acb6c5c3
commit 7edad955a2
2 changed files with 7 additions and 3 deletions

View File

@@ -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]]: ...

View File

@@ -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: ...