Returns explicit package bases to use if the option is enabled, or None if disabled. We currently use MYPYPATH and the current directory as the package bases. In the future, when --namespace-packages is the default could also use the values passed with the --package-root flag, see #9632
(options: Options)
| 79 | |
| 80 | |
| 81 | def get_explicit_package_bases(options: Options) -> list[str] | None: |
| 82 | """Returns explicit package bases to use if the option is enabled, or None if disabled. |
| 83 | |
| 84 | We currently use MYPYPATH and the current directory as the package bases. In the future, |
| 85 | when --namespace-packages is the default could also use the values passed with the |
| 86 | --package-root flag, see #9632. |
| 87 | |
| 88 | Values returned are normalised so we can use simple string comparisons in |
| 89 | SourceFinder.is_explicit_package_base |
| 90 | """ |
| 91 | if not options.explicit_package_bases: |
| 92 | return None |
| 93 | roots = mypy_path() + options.mypy_path + [os.getcwd()] |
| 94 | return [normalise_package_base(root) for root in roots] |
| 95 | |
| 96 | |
| 97 | class SourceFinder: |
no test coverage detected
searching dependent graphs…