From 56d5f8c26c8058590f45332681c3014a63bde472 Mon Sep 17 00:00:00 2001 From: Gerhard Kotze Date: Thu, 14 May 2020 12:40:28 +0200 Subject: [PATCH] Handle get_model calls with linebreaks before and after arguments For example code formatted with `black` could look something like this and is not picked up by the existing regex FreakishlyLongerThanUsualModel = get_model( 'longerthanusualapp', 'FreakishlyLongerThanUsualModel' ) --- django_migration_linter/migration_linter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_migration_linter/migration_linter.py b/django_migration_linter/migration_linter.py index 2296cd3..8e2708d 100644 --- a/django_migration_linter/migration_linter.py +++ b/django_migration_linter/migration_linter.py @@ -443,7 +443,7 @@ class MigrationLinter(object): for model in called_models: has_get_model_call = ( re.search( - r"get_model\(.*?,.*?{}.+?\)".format(model), reverse_code_source + r"get_model\(\s*?.*?,.*?{}.+?\s*?\)".format(model), reverse_code_source ) is not None )