From 2b4f58199ae210b0c177808e1850d46edac71d90 Mon Sep 17 00:00:00 2001 From: Oliver Haas Date: Tue, 3 Jun 2025 19:40:22 +0200 Subject: [PATCH 1/2] fix: skip empty migrations folders --- syzygy/checks.py | 5 +++++ tests/test_checks.py | 7 +++++++ tests/test_migrations/empty/.gitkeep | 1 + 3 files changed, 13 insertions(+) create mode 100644 tests/test_migrations/empty/.gitkeep diff --git a/syzygy/checks.py b/syzygy/checks.py index cf519d6..a8d9103 100644 --- a/syzygy/checks.py +++ b/syzygy/checks.py @@ -30,7 +30,12 @@ def check_migrations(app_configs, **kwargs): except ImportError: # This is not the place to deal with migration issues. continue + if module.__file__ is None: + # Skip empty migration folders, which can happen + # for example when switching between branches. + continue directory = os.path.dirname(module.__file__) + migration_names = set() for name in os.listdir(directory): if name.endswith(".py"): diff --git a/tests/test_checks.py b/tests/test_checks.py index aa231e0..0f47c07 100644 --- a/tests/test_checks.py +++ b/tests/test_checks.py @@ -29,3 +29,10 @@ def test_ambiguous_stage(self): id="migrations.0001", ), ) + + def test_empty_migration_folder(self): + with self.settings(MIGRATION_MODULES={"tests": "tests.test_migrations.empty"}): + checks = run_checks( + app_configs=[apps.get_app_config("tests")], tags={"migrations"} + ) + self.assertEqual(len(checks), 0) diff --git a/tests/test_migrations/empty/.gitkeep b/tests/test_migrations/empty/.gitkeep new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/tests/test_migrations/empty/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file From f903c0b53cf948c2132355b3fe4329ad111d5b8f Mon Sep 17 00:00:00 2001 From: Oliver Haas Date: Tue, 3 Jun 2025 19:46:10 +0200 Subject: [PATCH 2/2] chore: remove added empty line --- syzygy/checks.py | 1 - 1 file changed, 1 deletion(-) diff --git a/syzygy/checks.py b/syzygy/checks.py index a8d9103..fe5a3a6 100644 --- a/syzygy/checks.py +++ b/syzygy/checks.py @@ -35,7 +35,6 @@ def check_migrations(app_configs, **kwargs): # for example when switching between branches. continue directory = os.path.dirname(module.__file__) - migration_names = set() for name in os.listdir(directory): if name.endswith(".py"):