Adapt 'warnings-as-errors' option to allow taking migration test codes as input

This commit is contained in:
David Wobrock committed 2022-03-13 17:26:40 +01:00
1 parent a04ecc078a
commit c7d9129db9
8 files changed
+114 -33

No files matched your search

+17 -2
View File
@@ -21,8 +21,10 @@ def register_linting_configuration_options(parser):
parser.add_argument(
"--warnings-as-errors",
action="store_true",
help="handle warnings as errors",
type=str,
nargs="*",
help="handle warnings as errors. Optionally specify the tests to handle as "
"errors (e.g. RUNPYTHON_REVERSIBLE)",
)
@@ -35,3 +37,16 @@ def configure_logging(verbosity):
logger.disabled = True
else:
logging.basicConfig(format="%(message)s")
def extract_warnings_as_errors_option(warnings_as_errors):
if isinstance(warnings_as_errors, list):
warnings_as_errors_tests = warnings_as_errors
# If the option is specified but without any test codes,
# all warnings become errors
all_warnings_as_errors = len(warnings_as_errors) == 0
else:
warnings_as_errors_tests = None
all_warnings_as_errors = False
return warnings_as_errors_tests, all_warnings_as_errors