Return the path of the module source file or why it wasn't found. If fast_path is True, prioritize performance over generating detailed error descriptions.
(self, id: str, *, fast_path: bool = False)
| 307 | return components.get(id, []) |
| 308 | |
| 309 | def find_module(self, id: str, *, fast_path: bool = False) -> ModuleSearchResult: |
| 310 | """Return the path of the module source file or why it wasn't found. |
| 311 | |
| 312 | If fast_path is True, prioritize performance over generating detailed |
| 313 | error descriptions. |
| 314 | """ |
| 315 | if id not in self.results: |
| 316 | top_level = id.partition(".")[0] |
| 317 | use_typeshed = True |
| 318 | if id in self.stdlib_py_versions: |
| 319 | use_typeshed = self._typeshed_has_version(id) |
| 320 | elif top_level in self.stdlib_py_versions: |
| 321 | use_typeshed = self._typeshed_has_version(top_level) |
| 322 | result, should_cache = self._find_module(id, use_typeshed) |
| 323 | if should_cache: |
| 324 | if ( |
| 325 | not ( |
| 326 | fast_path or (self.options is not None and self.options.fast_module_lookup) |
| 327 | ) |
| 328 | and result is ModuleNotFoundReason.NOT_FOUND |
| 329 | and self._can_find_module_in_parent_dir(id) |
| 330 | ): |
| 331 | self.results[id] = ModuleNotFoundReason.WRONG_WORKING_DIRECTORY |
| 332 | else: |
| 333 | self.results[id] = result |
| 334 | return self.results[id] |
| 335 | else: |
| 336 | return result |
| 337 | return self.results[id] |
| 338 | |
| 339 | def _typeshed_has_version(self, module: str) -> bool: |
| 340 | if not self.options: |