This is stubtest! It's time to test the stubs!
(args: _Arguments, use_builtins_fixtures: bool = False)
| 2355 | |
| 2356 | |
| 2357 | def test_stubs(args: _Arguments, use_builtins_fixtures: bool = False) -> int: |
| 2358 | """This is stubtest! It's time to test the stubs!""" |
| 2359 | # Load the allowlist. This is a series of strings corresponding to Error.object_desc |
| 2360 | # Values in the dict will store whether we used the allowlist entry or not. |
| 2361 | allowlist = { |
| 2362 | entry: False |
| 2363 | for allowlist_file in args.allowlist |
| 2364 | for entry in get_allowlist_entries(allowlist_file) |
| 2365 | } |
| 2366 | allowlist_regexes = {entry: re.compile(entry) for entry in allowlist} |
| 2367 | |
| 2368 | # If we need to generate an allowlist, we store Error.object_desc for each error here. |
| 2369 | generated_allowlist = set() |
| 2370 | |
| 2371 | modules = args.modules |
| 2372 | if args.check_typeshed: |
| 2373 | if args.modules: |
| 2374 | print( |
| 2375 | _style("error:", color="red", bold=True), |
| 2376 | "cannot pass both --check-typeshed and a list of modules", |
| 2377 | ) |
| 2378 | return 1 |
| 2379 | typeshed_modules = get_typeshed_stdlib_modules(args.custom_typeshed_dir) |
| 2380 | runtime_modules = get_importable_stdlib_modules() |
| 2381 | modules = sorted((typeshed_modules | runtime_modules) - ANNOYING_STDLIB_MODULES) |
| 2382 | |
| 2383 | if not modules: |
| 2384 | print(_style("error:", color="red", bold=True), "no modules to check") |
| 2385 | return 1 |
| 2386 | |
| 2387 | options = Options() |
| 2388 | options.incremental = False |
| 2389 | options.custom_typeshed_dir = args.custom_typeshed_dir |
| 2390 | if options.custom_typeshed_dir: |
| 2391 | options.abs_custom_typeshed_dir = os.path.abspath(options.custom_typeshed_dir) |
| 2392 | options.config_file = args.mypy_config_file |
| 2393 | options.use_builtins_fixtures = use_builtins_fixtures |
| 2394 | options.show_traceback = args.show_traceback |
| 2395 | options.pdb = args.pdb |
| 2396 | options.pos_only_special_methods = False |
| 2397 | |
| 2398 | if options.config_file: |
| 2399 | |
| 2400 | def set_strict_flags() -> None: # not needed yet |
| 2401 | return |
| 2402 | |
| 2403 | parse_config_file(options, set_strict_flags, options.config_file, sys.stdout, sys.stderr) |
| 2404 | |
| 2405 | def error_callback(msg: str) -> typing.NoReturn: |
| 2406 | print(_style("error:", color="red", bold=True), msg) |
| 2407 | sys.exit(1) |
| 2408 | |
| 2409 | def warning_callback(msg: str) -> None: |
| 2410 | print(_style("warning:", color="yellow", bold=True), msg) |
| 2411 | |
| 2412 | options.process_error_codes(error_callback=error_callback) |
| 2413 | options.process_incomplete_features( |
| 2414 | error_callback=error_callback, warning_callback=warning_callback |
no test coverage detected
searching dependent graphs…