From 8a7cff3c8237ab8db29cc611e9b7a27cc6a2a7a8 Mon Sep 17 00:00:00 2001 From: David Wobrock Date: Sat, 20 Jun 2020 21:32:30 +0200 Subject: [PATCH] Add method to linter reset_counters --- django_migration_linter/migration_linter.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/django_migration_linter/migration_linter.py b/django_migration_linter/migration_linter.py index c5ea333..8134c19 100644 --- a/django_migration_linter/migration_linter.py +++ b/django_migration_linter/migration_linter.py @@ -72,11 +72,7 @@ class MigrationLinter(object): self.warnings_as_errors = warnings_as_errors # Initialise counters - self.nb_valid = 0 - self.nb_ignored = 0 - self.nb_warnings = 0 - self.nb_erroneous = 0 - self.nb_total = 0 + self.reset_counters() # Initialise cache. Read from old, write to new to prune old entries. if self.should_use_cache(): @@ -91,6 +87,13 @@ class MigrationLinter(object): connection=connections[self.database], load=True ) + def reset_counters(self): + self.nb_valid = 0 + self.nb_ignored = 0 + self.nb_warnings = 0 + self.nb_erroneous = 0 + self.nb_total = 0 + def should_use_cache(self): return self.django_path and not self.no_cache