MCPcopy
hub / github.com/python/mypy / _find_config_file

Function _find_config_file

mypy/config_parser.py:270–299  ·  view source on GitHub ↗
(
    stderr: TextIO | None = None,
)

Source from the content-addressed store, hash-verified

268
269
270def _find_config_file(
271 stderr: TextIO | None = None,
272) -> tuple[MutableMapping[str, Any], dict[str, _INI_PARSER_CALLABLE], str] | None:
273
274 current_dir = os.path.abspath(os.getcwd())
275
276 while True:
277 for name in defaults.CONFIG_NAMES + defaults.SHARED_CONFIG_NAMES:
278 config_file = os.path.relpath(os.path.join(current_dir, name))
279 ret = _parse_individual_file(config_file, stderr)
280 if ret is None:
281 continue
282 return ret
283
284 if any(
285 os.path.exists(os.path.join(current_dir, cvs_root)) for cvs_root in (".git", ".hg")
286 ):
287 break
288 parent_dir = os.path.dirname(current_dir)
289 if parent_dir == current_dir:
290 break
291 current_dir = parent_dir
292
293 for config_file in defaults.USER_CONFIG_FILES:
294 ret = _parse_individual_file(config_file, stderr)
295 if ret is None:
296 continue
297 return ret
298
299 return None
300
301
302def parse_config_file(

Callers 5

test_no_configMethod · 0.90
test_precedenceMethod · 0.90
parse_config_fileFunction · 0.85

Calls 4

_parse_individual_fileFunction · 0.85
anyFunction · 0.85
existsMethod · 0.80
joinMethod · 0.45

Tested by 4

test_no_configMethod · 0.72
test_precedenceMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…