Skip to content

Commit 8cf5416

Browse files
authored
Disallow unsupported options (#112)
Drop support for Python 3.8, due to dropped support for Python 3.8 in a test dependency (dj-database-url).
1 parent 9315dfa commit 8cf5416

7 files changed

Lines changed: 38 additions & 21 deletions

File tree

.github/workflows/build.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ jobs:
1414
- "5.1"
1515
- "5.2"
1616
python-version:
17-
- "3.8"
1817
- "3.9"
1918
- "3.10"
2019
- "3.11"
@@ -28,20 +27,14 @@ jobs:
2827
exclude:
2928
- django-version: "4.2"
3029
python-version: "3.13"
31-
- django-version: "5.0"
32-
python-version: "3.8"
3330
- django-version: "5.0"
3431
python-version: "3.9"
3532
- django-version: "5.0"
3633
python-version: "3.13"
37-
- django-version: "5.1"
38-
python-version: "3.8"
3934
- django-version: "5.1"
4035
python-version: "3.9"
4136
- django-version: "5.1"
4237
python-version: "3.13"
43-
- django-version: "5.2"
44-
python-version: "3.8"
4538
- django-version: "5.2"
4639
python-version: "3.9"
4740

HISTORY.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
6.0 (2025-06-03)
2+
++++++++++++++++
3+
4+
* Drop support for Python 3.8.
5+
* Raise errors early for unsupported options,
6+
including ``--fake-initial``, ``--plan``, ``--check``,
7+
``--prune``, and ``--run-syncdb``.
8+
19
5.3 (2025-04-02)
210
++++++++++++++++
311

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ then add this to the ``repos`` key of your ``.pre-commit-config.yaml``:
111111
112112
repos:
113113
- repo: https://github.com/ryanhiebert/django-safemigrate
114-
rev: "5.3"
114+
rev: "6.0"
115115
hooks:
116116
- id: check
117117

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "django-safemigrate"
7-
version = "5.3"
7+
version = "6.0"
88
description = "Safely run migrations before deployment"
99
authors = [{ name = "Ryan Hiebert", email = "ryan@ryanhiebert.com" }]
1010
license = { text = "MIT" }
1111
readme = "README.rst"
12-
requires-python = ">=3.8"
12+
requires-python = ">=3.9"
1313
dependencies = ["django>=4.2"]
1414

1515
[project.urls]

src/django_safemigrate/management/commands/safemigrate.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,16 @@ class Command(migrate.Command):
4949
receiver_has_run = False
5050

5151
def handle(self, *args, **options):
52-
fake = options.get("fake", False)
53-
if fake:
52+
if options.get("fake") or options.get("fake_initial"):
5453
raise CommandError("Safemigrate does not support faking migrations.")
54+
if options.get("plan"):
55+
raise CommandError("Safemigrate does not support the plan option.")
56+
if options.get("check_unapplied"):
57+
raise CommandError("Safemigrate does not support the check_unapplied option.")
58+
if options.get("prune"):
59+
raise CommandError("Safemigrate does not support the prune option.")
60+
if options.get("run_syncdb"):
61+
raise CommandError("Safemigrate does not support the run_syncdb option.")
5562

5663
# Only connect the handler when this command is run to
5764
# avoid running for tests.

tests/safemigrate_test.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -640,11 +640,20 @@ def test_migrations_detected_when_blocked_nonstrict(self, settings, receiver):
640640
assert len(plan) == 1
641641
assert SafeMigration.objects.count() == 1
642642

643-
def test_disallow_faking(self):
644-
"""Safemigrate does not support faking migrations."""
645-
command = Command()
643+
def test_disallow_unsupported_options(self):
644+
"""Early error if using an unsupported option."""
645+
with pytest.raises(CommandError):
646+
Command().handle(fake=True)
647+
with pytest.raises(CommandError):
648+
Command().handle(fake_initial=True)
649+
with pytest.raises(CommandError):
650+
Command().handle(plan=True)
651+
with pytest.raises(CommandError):
652+
Command().handle(check_unapplied=True)
653+
with pytest.raises(CommandError):
654+
Command().handle(prune=True)
646655
with pytest.raises(CommandError):
647-
command.handle(fake=True)
656+
Command().handle(run_syncdb=True)
648657
assert not SafeMigration.objects.exists()
649658

650659
def test_migrations_are_detected(self, receiver):

tox.ini

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[tox]
22
isolated_build = True
33
envlist =
4-
dj{42 }-py{38,39,310,311,312 }
5-
dj{50 }-py{ 310,311,312 }
6-
dj{51 }-py{ 310,311,312,313}
7-
dj{52 }-py{ 310,311,312,313}
8-
dj{main}-py{ 312,313}
4+
dj{42 }-py{39,310,311,312 }
5+
dj{50 }-py{ 310,311,312 }
6+
dj{51 }-py{ 310,311,312,313}
7+
dj{52 }-py{ 310,311,312,313}
8+
dj{main}-py{ 312,313}
99

1010
[testenv]
1111
deps =

0 commit comments

Comments
 (0)