Skip to content

ast.get_docstring: wrong return type #4575

@blueyed

Description

@blueyed

At least in recent Python versions it can return None: https://github.com/python/cpython/blob/0705ec8a149e27023b0420ae0366d16255f6c9f7/Lib/ast.py#L270-L293

typed_ast also seems to be affected, but has Optional[bytes] already:

stdlib/3/ast.pyi
194:def get_docstring(node: AST, clean: bool = ...) -> str: ...

third_party/3/typed_ast/ast27.pyi
15:def get_docstring(node: AST, clean: bool = ...) -> Optional[bytes]: ...

third_party/3/typed_ast/ast3.pyi
15:def get_docstring(node: AST, clean: bool = ...) -> str: ...

stdlib/2/ast.pyi
16:def get_docstring(node: AST, clean: bool = ...) -> str: ...

(@ 675ab77)

Metadata

Metadata

Assignees

No one assigned

    Labels

    stubs: false negativeType checkers do not report an error, but should

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions