Created
May 29, 2021 13:01
-
-
Save AABur/50faf30ab50def5ab3ec19dbbecbba35 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # FIXME: ward/_collect.py:61:1: C901 'get_info_for_modules' is too complex (15) | |
| def get_info_for_modules( | |
| paths: List[Path], exclude: Tuple[Glob] | |
| ) -> List[pkgutil.ModuleInfo]: | |
| logger.info("Start get_info_for_modules") | |
| paths = _remove_excluded_paths(set(paths), exclude) | |
| module_infos = [] | |
| # Handle case where path points directly to modules | |
| for path in paths: | |
| logger.info("Handle case where path points directly to modules") | |
| if path.is_file() and not _handled_within(path, paths): | |
| logger.info("if handleds") | |
| spec = importlib.util.spec_from_file_location(path.stem, path) | |
| module = get_module_directly(path, spec) | |
| module_infos.append(module) | |
| # Check for modules at the root of the specified path (or paths) | |
| for module in pkgutil.iter_modules([str(p) for p in paths if p.is_dir()]): | |
| logger.info("Check for modules at the root of the specified path (or paths)") | |
| if is_test_module(module) and not _is_excluded_module(module, exclude): | |
| logger.info("Next step0") | |
| module_infos.append(module) | |
| # Now check for modules in every subdirectory | |
| checked_dirs: Set[Path] = set(paths) | |
| for path in paths: | |
| logger.info("Now check for modules in every subdirectory") | |
| for root, dirs, _ in os.walk(str(path)): | |
| logger.info("Next step1") | |
| if _excluded(Path(root), exclude): | |
| logger.info("Next step2") | |
| continue | |
| for dir_name in dirs: | |
| logger.info("Next step3") | |
| dir_path = Path(root, dir_name) | |
| # ignore site-packages directories | |
| abs_path = dir_path.absolute() | |
| if str(abs_path).startswith(get_python_lib()): | |
| logger.info("Next step4") | |
| continue | |
| # if we have seen this path before, skip it | |
| if dir_path not in checked_dirs and not _excluded(dir_path, exclude): | |
| logger.info("if we have seen this path before, skip it") | |
| checked_dirs.add(dir_path) | |
| for module in pkgutil.iter_modules([str(dir_path)]): | |
| logger.info("Next step5") | |
| if is_test_module(module) and not _is_excluded_module( | |
| module, exclude | |
| ): | |
| logger.info("Next step6") | |
| module_infos.append(module) | |
| return module_infos |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 05-29 15:57 ward._collect INFO Start get_info_for_modules | |
| 05-29 15:57 ward._collect INFO Handle case where path points directly to modules | |
| 05-29 15:57 ward._collect INFO Check for modules at the root of the specified path (or paths) | |
| 05-29 15:57 ward._collect INFO Next step0 | |
| 05-29 15:57 ward._collect INFO Check for modules at the root of the specified path (or paths) | |
| 05-29 15:57 ward._collect INFO Next step0 | |
| 05-29 15:57 ward._collect INFO Check for modules at the root of the specified path (or paths) | |
| 05-29 15:57 ward._collect INFO Next step0 | |
| 05-29 15:57 ward._collect INFO Check for modules at the root of the specified path (or paths) | |
| 05-29 15:57 ward._collect INFO Next step0 | |
| 05-29 15:57 ward._collect INFO Check for modules at the root of the specified path (or paths) | |
| 05-29 15:57 ward._collect INFO Next step0 | |
| 05-29 15:57 ward._collect INFO Check for modules at the root of the specified path (or paths) | |
| 05-29 15:57 ward._collect INFO Next step0 | |
| 05-29 15:57 ward._collect INFO Check for modules at the root of the specified path (or paths) | |
| 05-29 15:57 ward._collect INFO Next step0 | |
| 05-29 15:57 ward._collect INFO Check for modules at the root of the specified path (or paths) | |
| 05-29 15:57 ward._collect INFO Next step0 | |
| 05-29 15:57 ward._collect INFO Check for modules at the root of the specified path (or paths) | |
| 05-29 15:57 ward._collect INFO Next step0 | |
| 05-29 15:57 ward._collect INFO Check for modules at the root of the specified path (or paths) | |
| 05-29 15:57 ward._collect INFO Next step0 | |
| 05-29 15:57 ward._collect INFO Check for modules at the root of the specified path (or paths) | |
| 05-29 15:57 ward._collect INFO Next step0 | |
| 05-29 15:57 ward._collect INFO Check for modules at the root of the specified path (or paths) | |
| 05-29 15:57 ward._collect INFO Next step0 | |
| 05-29 15:57 ward._collect INFO Check for modules at the root of the specified path (or paths) | |
| 05-29 15:57 ward._collect INFO Next step0 | |
| 05-29 15:57 ward._collect INFO Check for modules at the root of the specified path (or paths) | |
| 05-29 15:57 ward._collect INFO Now check for modules in every subdirectory | |
| 05-29 15:57 ward._collect INFO Next step1 | |
| 05-29 15:57 ward._collect INFO Next step3 | |
| 05-29 15:57 ward._collect INFO if we have seen this path before, skip it | |
| 05-29 15:57 ward._collect INFO Next step1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment