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

Function common_dir_prefix

mypy/stubutil.py:214–224  ·  view source on GitHub ↗
(paths: list[str])

Source from the content-addressed store, hash-verified

212
213
214def common_dir_prefix(paths: list[str]) -> str:
215 if not paths:
216 return "."
217 cur = os.path.dirname(os.path.normpath(paths[0]))
218 for path in paths[1:]:
219 while True:
220 path = os.path.dirname(os.path.normpath(path))
221 if (cur + os.sep).startswith(path + os.sep):
222 cur = path
223 break
224 return cur or "."
225
226
227class AnnotationPrinter(TypeStrVisitor):

Callers 3

generate_stubsFunction · 0.90

Calls 1

startswithMethod · 0.45

Tested by 2

Used in the wild real call sites across dependent graphs

searching dependent graphs…