Document, add to changelog the data migrations and rename to 'warnings-as-errors' (plural)
This commit is contained in:
1 parent
71614bd377
commit
e49f6dea9c
6 files changed
+21
-7
No files matched your search
@@ -1,3 +1,9 @@
|
||||
## 2.0.0
|
||||
|
||||
* Add linting on data migrations that will raise warnings
|
||||
* Add `--quiet warning` option to suppress warning messages
|
||||
* Add `--warnings-as-errors` option to handle warnings as errors
|
||||
|
||||
## 1.5.0
|
||||
|
||||
* Rework documentation.
|
||||
|
||||
@@ -110,7 +110,7 @@ class Command(BaseCommand):
|
||||
help="don't print linting messages to stdout",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--warning-as-error", action="store_true", help="handle warnings as errors",
|
||||
"--warnings-as-errors", action="store_true", help="handle warnings as errors",
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
@@ -139,7 +139,7 @@ class Command(BaseCommand):
|
||||
only_unapplied_migrations=options["unapplied_migrations"],
|
||||
exclude_migration_tests=options["exclude_migration_tests"],
|
||||
quiet=options["quiet"],
|
||||
warning_as_error=options["warning_as_error"],
|
||||
warnings_as_errors=options["warnings_as_errors"],
|
||||
)
|
||||
linter.lint_all_migrations(
|
||||
git_commit_id=options["commit_id"],
|
||||
|
||||
@@ -52,7 +52,7 @@ class MigrationLinter(object):
|
||||
only_unapplied_migrations=False,
|
||||
exclude_migration_tests=None,
|
||||
quiet=None,
|
||||
warning_as_error=False,
|
||||
warnings_as_errors=False,
|
||||
):
|
||||
# Store parameters and options
|
||||
self.django_path = path
|
||||
@@ -67,7 +67,7 @@ class MigrationLinter(object):
|
||||
self.only_applied_migrations = only_applied_migrations
|
||||
self.only_unapplied_migrations = only_unapplied_migrations
|
||||
self.quiet = quiet or []
|
||||
self.warning_as_error = warning_as_error
|
||||
self.warnings_as_errors = warnings_as_errors
|
||||
|
||||
# Initialise counters
|
||||
self.nb_valid = 0
|
||||
@@ -142,7 +142,7 @@ class MigrationLinter(object):
|
||||
if ignored_data:
|
||||
ignored += ignored_data
|
||||
|
||||
if self.warning_as_error:
|
||||
if self.warnings_as_errors:
|
||||
errors += warnings
|
||||
warnings = []
|
||||
|
||||
|
||||
@@ -12,3 +12,10 @@ The linter analyses your migrations and checks the SQL for:
|
||||
|
||||
Those are the most important and frequent backward incompatible migrations.
|
||||
We are happy to add more if you can specify them to us.
|
||||
|
||||
|
||||
## Warnings
|
||||
|
||||
On data migrations, the linter will show a warning when:
|
||||
* you are missing a reverse migration
|
||||
* the RunPython arguments do not respect the naming convention `apps, schema_editor`
|
||||
@@ -25,6 +25,7 @@ Detailed command line options:
|
||||
|`--project-root-path DJANGO_PROJECT_FOLDER` | An absolute or relative path to the django project. |
|
||||
|`--include-migrations-from FILE_PATH` | If specified, only migrations listed in the given file will be considered. |
|
||||
|`--quiet or -q {ok,ignore,warning,error}` | Suppress certain output messages, instead of writing them to stdout. |
|
||||
|`--warnings-as-errors` | Handle warnings as errors and therefore return an error status code if we should. |
|
||||
|
||||
## Ignoring migration tests
|
||||
|
||||
|
||||
@@ -49,11 +49,11 @@ class DataMigrationDetectionTestCase(unittest.TestCase):
|
||||
self.assertEqual(1, self.linter.nb_valid)
|
||||
self.assertFalse(self.linter.has_errors)
|
||||
|
||||
def test_warning_as_error(self):
|
||||
def test_warnings_as_errors(self):
|
||||
self.linter = MigrationLinter(
|
||||
self.test_project_path,
|
||||
include_apps=fixtures.DATA_MIGRATIONS,
|
||||
warning_as_error=True,
|
||||
warnings_as_errors=True,
|
||||
)
|
||||
|
||||
reverse_migration = self.linter.migration_loader.disk_migrations[
|
||||
|
||||
Reference in new issue
Block a user