Test if a module can be found by checking the parent directories of the current working directory.
(self, id: str)
| 378 | path = os.path.dirname(path) |
| 379 | |
| 380 | def _can_find_module_in_parent_dir(self, id: str) -> bool: |
| 381 | """Test if a module can be found by checking the parent directories |
| 382 | of the current working directory. |
| 383 | """ |
| 384 | working_dir = os.getcwd() |
| 385 | parent_search = FindModuleCache( |
| 386 | SearchPaths((), (), (), ()), |
| 387 | self.fscache, |
| 388 | self.options, |
| 389 | stdlib_py_versions=self.stdlib_py_versions, |
| 390 | ) |
| 391 | while any(is_init_file(file) for file in os.listdir(working_dir)): |
| 392 | working_dir = os.path.dirname(working_dir) |
| 393 | parent_search.search_paths = SearchPaths((working_dir,), (), (), ()) |
| 394 | if not isinstance(parent_search._find_module(id, False)[0], ModuleNotFoundReason): |
| 395 | return True |
| 396 | return False |
| 397 | |
| 398 | def _find_module(self, id: str, use_typeshed: bool) -> tuple[ModuleSearchResult, bool]: |
| 399 | """Try to find a module in all available sources. |
no test coverage detected