Construct mypy BuildSources and Options from file and options lists
(
mypy_options: list[str],
only_compile_paths: Iterable[str] | None,
compiler_options: CompilerOptions,
fscache: FileSystemCache | None,
)
| 202 | |
| 203 | |
| 204 | def get_mypy_config( |
| 205 | mypy_options: list[str], |
| 206 | only_compile_paths: Iterable[str] | None, |
| 207 | compiler_options: CompilerOptions, |
| 208 | fscache: FileSystemCache | None, |
| 209 | ) -> tuple[list[BuildSource], list[BuildSource], Options]: |
| 210 | """Construct mypy BuildSources and Options from file and options lists""" |
| 211 | all_sources, options = process_options(mypy_options, fscache=fscache, mypyc=True) |
| 212 | if only_compile_paths is not None: |
| 213 | paths_set = set(only_compile_paths) |
| 214 | mypyc_sources = [s for s in all_sources if s.path in paths_set] |
| 215 | else: |
| 216 | mypyc_sources = all_sources |
| 217 | |
| 218 | if compiler_options.separate: |
| 219 | mypyc_sources = [src for src in mypyc_sources if src.path] |
| 220 | |
| 221 | if not mypyc_sources: |
| 222 | return mypyc_sources, all_sources, options |
| 223 | |
| 224 | # Override whatever python_version is inferred from the .ini file, |
| 225 | # and set the python_version to be the currently used version. |
| 226 | options.python_version = sys.version_info[:2] |
| 227 | |
| 228 | if options.python_version[0] == 2: |
| 229 | fail("Python 2 not supported") |
| 230 | if not options.strict_optional: |
| 231 | fail("Disabling strict optional checking not supported") |
| 232 | options.show_traceback = True |
| 233 | # Needed to get types for all AST nodes |
| 234 | options.export_types = True |
| 235 | # We use mypy incremental mode when doing separate/incremental mypyc compilation |
| 236 | options.incremental = compiler_options.separate |
| 237 | options.preserve_asts = True |
| 238 | |
| 239 | for source in mypyc_sources: |
| 240 | options.per_module_options.setdefault(source.module, {})["mypyc"] = True |
| 241 | |
| 242 | return mypyc_sources, all_sources, options |
| 243 | |
| 244 | |
| 245 | def is_package_source(source: BuildSource) -> bool: |
no test coverage detected
searching dependent graphs…