MCPcopy Index your code
hub / github.com/python/mypy / get_explicit_package_bases

Function get_explicit_package_bases

mypy/find_sources.py:81–94  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

79
80
81def 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
97class SourceFinder:

Callers 1

__init__Method · 0.85

Calls 2

mypy_pathFunction · 0.90
normalise_package_baseFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…