Refactor linting configuration parser options to a function

This commit is contained in:
David Wobrock committed 2020-07-02 19:15:30 +02:00
1 parent e86f8a7df2
commit a9cae8a21e
2 files changed
+23 -13

No files matched your search

@@ -5,6 +5,7 @@ from importlib import import_module
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from ..utils import register_linting_configuration_options
from ...constants import __version__ from ...constants import __version__
from ...migration_linter import MigrationLinter, MessageType from ...migration_linter import MigrationLinter, MessageType
@@ -94,14 +95,6 @@ class Command(BaseCommand):
help="check only migrations that have already been applied to the database", help="check only migrations that have already been applied to the database",
) )
parser.add_argument(
"--exclude-migration-tests",
type=str,
nargs="*",
help="Specify backward incompatible migration tests "
"to be ignored (e.g. ALTER_COLUMN)",
)
parser.add_argument( parser.add_argument(
"-q", "-q",
"--quiet", "--quiet",
@@ -109,11 +102,7 @@ class Command(BaseCommand):
choices=MessageType.values(), choices=MessageType.values(),
help="don't print linting messages to stdout", help="don't print linting messages to stdout",
) )
parser.add_argument( register_linting_configuration_options(parser)
"--warnings-as-errors",
action="store_true",
help="handle warnings as errors",
)
def handle(self, *args, **options): def handle(self, *args, **options):
if options["project_root_path"]: if options["project_root_path"]:
@@ -0,0 +1,21 @@
def register_linting_configuration_options(parser):
parser.add_argument(
"--database",
type=str,
nargs="?",
help=(
"specify the database for which to generate the SQL. " "Defaults to default"
),
)
parser.add_argument(
"--exclude-migration-tests",
type=str,
nargs="*",
help="Specify backward incompatible migration tests "
"to be ignored (e.g. ALTER_COLUMN)",
)
parser.add_argument(
"--warnings-as-errors", action="store_true", help="handle warnings as errors",
)