(self, program_text: str, extra: list[str])
| 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) |
no test coverage detected