From 4fd264b6f1737b0317fdd95b3d7ff3bba15ae6c3 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Wed, 12 Aug 2015 09:10:39 -0400 Subject: [PATCH] Refs #24351 -- Removed support for the old allow_migrate() signature per deprecation timeline. --- django/db/utils.py | 24 +----------------------- docs/topics/db/multi-db.txt | 6 ------ tests/multiple_database/tests.py | 32 -------------------------------- 3 files changed, 1 insertion(+), 61 deletions(-) diff --git a/django/db/utils.py b/django/db/utils.py index 380a4b9554..aaa992c040 100644 --- a/django/db/utils.py +++ b/django/db/utils.py @@ -1,7 +1,5 @@ -import inspect import os import pkgutil -import warnings from importlib import import_module from threading import local @@ -9,7 +7,6 @@ from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.utils import six from django.utils._os import npath, upath -from django.utils.deprecation import RemovedInDjango110Warning from django.utils.functional import cached_property from django.utils.module_loading import import_string @@ -298,26 +295,7 @@ class ConnectionRouter(object): # If the router doesn't have a method, skip to the next one. continue - if six.PY3: - sig = inspect.signature(router.allow_migrate) - has_deprecated_signature = not any( - p.kind == inspect.Parameter.VAR_KEYWORD for p in sig.parameters.values() - ) - else: - argspec = inspect.getargspec(router.allow_migrate) - has_deprecated_signature = len(argspec.args) == 3 and not argspec.keywords - - if has_deprecated_signature: - warnings.warn( - "The signature of allow_migrate has changed from " - "allow_migrate(self, db, model) to " - "allow_migrate(self, db, app_label, model_name=None, **hints). " - "Support for the old signature will be removed in Django 1.10.", - RemovedInDjango110Warning) - model = hints.get('model') - allow = None if model is None else method(db, model) - else: - allow = method(db, app_label, **hints) + allow = method(db, app_label, **hints) if allow is not None: return allow diff --git a/docs/topics/db/multi-db.txt b/docs/topics/db/multi-db.txt index fca21388c9..f11c9512e5 100644 --- a/docs/topics/db/multi-db.txt +++ b/docs/topics/db/multi-db.txt @@ -182,12 +182,6 @@ A database Router is a class that provides up to four methods: keys, extra tables, or missing tables if you change it once you have applied some migrations. - .. versionchanged:: 1.8 - - The signature of ``allow_migrate`` has changed significantly from previous - versions. See the :ref:`deprecation notes - ` for more details. - A router doesn't have to provide *all* these methods -- it may omit one or more of them. If one of the methods is omitted, Django will skip that router when performing the relevant check. diff --git a/tests/multiple_database/tests.py b/tests/multiple_database/tests.py index fd7748e9f9..f6b529adf7 100644 --- a/tests/multiple_database/tests.py +++ b/tests/multiple_database/tests.py @@ -2,7 +2,6 @@ from __future__ import unicode_literals import datetime import pickle -import warnings from operator import attrgetter from django.contrib.auth.models import User @@ -12,7 +11,6 @@ from django.db import DEFAULT_DB_ALIAS, connections, router, transaction from django.db.models import signals from django.db.utils import ConnectionRouter from django.test import SimpleTestCase, TestCase, override_settings -from django.utils.encoding import force_text from django.utils.six import StringIO from .models import Book, Person, Pet, Review, UserProfile @@ -1062,36 +1060,6 @@ class RouterTestCase(TestCase): self.assertTrue(router.allow_migrate_model('other', User)) self.assertTrue(router.allow_migrate_model('other', Book)) - def test_migrate_legacy_router(self): - class LegacyRouter(object): - def allow_migrate(self, db, model): - """ - Deprecated allow_migrate signature should trigger - RemovedInDjango110Warning. - """ - assert db == 'default' - assert model is User - return True - - with override_settings(DATABASE_ROUTERS=[LegacyRouter()]): - with warnings.catch_warnings(record=True) as recorded: - warnings.filterwarnings('always') - - msg = ( - "The signature of allow_migrate has changed from " - "allow_migrate(self, db, model) to " - "allow_migrate(self, db, app_label, model_name=None, **hints). " - "Support for the old signature will be removed in Django 1.10." - ) - - self.assertTrue(router.allow_migrate_model('default', User)) - self.assertEqual(force_text(recorded.pop().message), msg) - - self.assertEqual(recorded, []) - - self.assertTrue(router.allow_migrate('default', 'app_label')) - self.assertEqual(force_text(recorded.pop().message), msg) - def test_partial_router(self): "A router can choose to implement a subset of methods" dive = Book.objects.using('other').create(title="Dive into Python",