44from contextlib import suppress
55from copy import deepcopy
66from importlib import import_module
7- from pathlib import Path
87from typing import TYPE_CHECKING , Any , Dict , Optional , Tuple
98
109from ._optionals import import_typeshed_client , typeshed_client_support
@@ -105,9 +104,7 @@ def find(self, node: ast.AST, method_name: str) -> Optional[ast.FunctionDef]:
105104def get_stubs_resolver ():
106105 global stubs_resolver
107106 if not stubs_resolver :
108- search_path = [Path (p ) for p in sys .path ]
109- search_context = tc .get_search_context (search_path = search_path )
110- stubs_resolver = StubsResolver (search_context = search_context )
107+ stubs_resolver = StubsResolver ()
111108 return stubs_resolver
112109
113110
@@ -134,8 +131,8 @@ def get_source_module(path: str, component) -> tc.ModulePath:
134131
135132
136133class StubsResolver (tc .Resolver ):
137- def __init__ (self , search_context = None ) -> None :
138- super ().__init__ (search_context )
134+ def __init__ (self , ** kwargs ) -> None :
135+ super ().__init__ (** kwargs )
139136 self ._module_ast_cache : Dict [str , Optional [ast .AST ]] = {}
140137 self ._module_assigns_cache : Dict [str , Dict [str , ast .Assign ]] = {}
141138 self ._module_imports_cache : Dict [str , Dict [str , Tuple [Optional [str ], str ]]] = {}
@@ -144,8 +141,8 @@ def get_imported_info(self, path: str, component=None) -> Optional[tc.ImportedIn
144141 resolved = self .get_fully_qualified_name (path )
145142 imported_info = None
146143 if isinstance (resolved , tc .ImportedInfo ):
147- resolved = resolved . info
148- if isinstance (resolved , tc .NameInfo ):
144+ imported_info = resolved
145+ elif isinstance (resolved , tc .NameInfo ):
149146 source_module = get_source_module (path , component )
150147 imported_info = tc .ImportedInfo (source_module = source_module , info = resolved )
151148 return imported_info
0 commit comments