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

Method get_init_file

mypy/find_sources.py:226–239  ·  view source on GitHub ↗

Check whether a directory contains a file named __init__.py[i]. If so, return the file's name (with dir prefixed). If not, return None. This prefers .pyi over .py (because of the ordering of PY_EXTENSIONS).

(self, dir: str)

Source from the content-addressed store, hash-verified

224 return module_join(mod_prefix, name), base_dir
225
226 def get_init_file(self, dir: str) -> str | None:
227 """Check whether a directory contains a file named __init__.py[i].
228
229 If so, return the file's name (with dir prefixed). If not, return None.
230
231 This prefers .pyi over .py (because of the ordering of PY_EXTENSIONS).
232 """
233 for ext in PY_EXTENSIONS:
234 f = os.path.join(dir, "__init__" + ext)
235 if self.fscache.isfile(f):
236 return f
237 if ext == ".py" and self.fscache.init_under_package_root(f):
238 return f
239 return None
240
241
242def module_join(parent: str, child: str) -> str:

Callers 1

_crawl_up_helperMethod · 0.95

Calls 3

joinMethod · 0.45
isfileMethod · 0.45

Tested by

no test coverage detected