diff --git a/django/db/migrations/state.py b/django/db/migrations/state.py index 088f5c41f0..6e023415bd 100644 --- a/django/db/migrations/state.py +++ b/django/db/migrations/state.py @@ -91,10 +91,11 @@ class ProjectState: def __init__(self, models=None, real_apps=None): self.models = models or {} # Apps to include from main registry, usually unmigrated ones - if real_apps: - self.real_apps = real_apps if isinstance(real_apps, set) else set(real_apps) + if real_apps is None: + real_apps = set() else: - self.real_apps = set() + assert isinstance(real_apps, set) + self.real_apps = real_apps self.is_delayed = False # {remote_model_key: {model_key: [(field_name, field)]}} self.relations = None diff --git a/docs/releases/4.0.txt b/docs/releases/4.0.txt index 0fa87b2810..24ce7285e0 100644 --- a/docs/releases/4.0.txt +++ b/docs/releases/4.0.txt @@ -544,6 +544,10 @@ Miscellaneous * The undocumented ``TRANSLATOR_COMMENT_MARK`` constant is moved from ``django.template.base`` to ``django.utils.translation.template``. +* The ``real_apps`` argument of the undocumented + ``django.db.migrations.state.ProjectState.__init__()`` method must now be a + set if provided. + .. _deprecated-features-4.0: Features deprecated in 4.0 diff --git a/tests/migrations/test_state.py b/tests/migrations/test_state.py index 01ffc48802..5be29ca2f1 100644 --- a/tests/migrations/test_state.py +++ b/tests/migrations/test_state.py @@ -924,6 +924,10 @@ class StateTests(SimpleTestCase): 1, ) + def test_real_apps_non_set(self): + with self.assertRaises(AssertionError): + ProjectState(real_apps=['contenttypes']) + def test_ignore_order_wrt(self): """ Makes sure ProjectState doesn't include OrderWrt fields when