From ed41f9a50ca0dd364dc92916d7c86727021d2694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20S=C5=82awecki?= Date: Mon, 16 Dec 2024 04:07:14 +0100 Subject: [PATCH] Narrow AST parsing result type to `ast.Module` at all times (#116) --- typeshed_client/finder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/typeshed_client/finder.py b/typeshed_client/finder.py index 9732406..2a006c2 100644 --- a/typeshed_client/finder.py +++ b/typeshed_client/finder.py @@ -105,7 +105,7 @@ def get_stub_file( def get_stub_ast( module_name: str, *, search_context: Optional[SearchContext] = None -) -> Optional[ast.AST]: +) -> Optional[ast.Module]: """Return the AST for the stub for the given module name.""" path = get_stub_file(module_name, search_context=search_context) if path is None: @@ -366,7 +366,7 @@ def find_typeshed() -> Path: return importlib_resources.files("typeshed_client") / "typeshed" -def parse_stub_file(path: Path) -> ast.AST: +def parse_stub_file(path: Path) -> ast.Module: text = path.read_text() return ast.parse(text, filename=str(path))