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

Method parse_flags

mypy/test/teststubgen.py:904–926  ·  view source on GitHub ↗
(self, program_text: str, extra: list[str])

Source from the content-addressed store, hash-verified

902 shutil.rmtree(out_dir)
903
904 def parse_flags(self, program_text: str, extra: list[str]) -> Options:
905 flags = re.search("# flags: (.*)$", program_text, flags=re.MULTILINE)
906 pyversion = None
907 if flags:
908 flag_list = flags.group(1).split()
909 for i, flag in enumerate(flag_list):
910 if flag.startswith("--python-version="):
911 pyversion = flag.split("=", 1)[1]
912 del flag_list[i]
913 break
914 else:
915 flag_list = []
916 options = parse_options(flag_list + extra)
917 if pyversion:
918 # A hack to allow testing old python versions with new language constructs
919 # This should be rarely used in general as stubgen output should not be version-specific
920 major, minor = pyversion.split(".", 1)
921 options.pyversion = (int(major), int(minor))
922 if "--verbose" not in flag_list:
923 options.quiet = True
924 else:
925 options.verbose = True
926 return options
927
928 def parse_modules(self, program_text: str) -> list[str]:
929 modules = re.search("# modules: (.*)$", program_text, flags=re.MULTILINE)

Callers 1

run_case_innerMethod · 0.95

Calls 6

parse_optionsFunction · 0.90
enumerateFunction · 0.85
intClass · 0.85
splitMethod · 0.80
groupMethod · 0.80
startswithMethod · 0.45

Tested by

no test coverage detected