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

Function highest_init_level

mypy/modulefinder.py:772–784  ·  view source on GitHub ↗

Compute the highest level where an __init__ file is found.

(fscache: FileSystemCache, id: str, path: str, prefix: str)

Source from the content-addressed store, hash-verified

770
771
772def highest_init_level(fscache: FileSystemCache, id: str, path: str, prefix: str) -> int:
773 """Compute the highest level where an __init__ file is found."""
774 if is_init_file(path):
775 path = os.path.dirname(path)
776 level = 0
777 for i in range(id.count(".")):
778 path = os.path.dirname(path)
779 if any(
780 fscache.isfile_case(os_path_join(path, f"__init__{extension}"), prefix)
781 for extension in PYTHON_EXTENSIONS
782 ):
783 level = i + 1
784 return level
785
786
787def mypy_path() -> list[str]:

Callers 1

_find_moduleMethod · 0.85

Calls 6

os_path_joinFunction · 0.90
is_init_fileFunction · 0.85
rangeClass · 0.85
anyFunction · 0.85
countMethod · 0.45
isfile_caseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…