diff --git a/django/contrib/postgres/fields/array.py b/django/contrib/postgres/fields/array.py index b87575235e4..e00e7ac8036 100644 --- a/django/contrib/postgres/fields/array.py +++ b/django/contrib/postgres/fields/array.py @@ -6,7 +6,6 @@ from django.contrib.postgres.validators import ArrayMaxLengthValidator from django.core import checks, exceptions from django.db.models import Field, IntegerField, Transform from django.db.models.lookups import Exact, In -from django.utils.inspect import func_supports_parameter from django.utils.translation import gettext_lazy as _ from ..utils import prefix_validation_error @@ -112,9 +111,7 @@ class ArrayField(CheckFieldDefaultMixin, Field): if value is None: return value return [ - self.base_field.from_db_value(item, expression, connection, {}) - if func_supports_parameter(self.base_field.from_db_value, 'context') # RemovedInDjango30Warning - else self.base_field.from_db_value(item, expression, connection) + self.base_field.from_db_value(item, expression, connection) for item in value ] diff --git a/django/core/cache/backends/db.py b/django/core/cache/backends/db.py index 21b5aa88ad5..17b52096599 100644 --- a/django/core/cache/backends/db.py +++ b/django/core/cache/backends/db.py @@ -7,7 +7,6 @@ from django.conf import settings from django.core.cache.backends.base import DEFAULT_TIMEOUT, BaseCache from django.db import DatabaseError, connections, models, router, transaction from django.utils import timezone -from django.utils.inspect import func_supports_parameter class Options: @@ -85,10 +84,7 @@ class DatabaseCache(BaseDatabaseCache): converters = (connection.ops.get_db_converters(expression) + expression.get_db_converters(connection)) for key, value, expires in rows: for converter in converters: - if func_supports_parameter(converter, 'context'): # RemovedInDjango30Warning - expires = converter(expires, expression, connection, {}) - else: - expires = converter(expires, expression, connection) + expires = converter(expires, expression, connection) if expires < timezone.now(): expired_keys.append(key) else: @@ -160,10 +156,7 @@ class DatabaseCache(BaseDatabaseCache): expression = models.Expression(output_field=models.DateTimeField()) for converter in (connection.ops.get_db_converters(expression) + expression.get_db_converters(connection)): - if func_supports_parameter(converter, 'context'): # RemovedInDjango30Warning - current_expires = converter(current_expires, expression, connection, {}) - else: - current_expires = converter(current_expires, expression, connection) + current_expires = converter(current_expires, expression, connection) exp = connection.ops.adapt_datetimefield_value(exp) if result and mode == 'touch': diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index 3e04a801e93..87852bcebb5 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -1,5 +1,4 @@ import collections -import functools import re import warnings from itertools import chain @@ -14,10 +13,7 @@ from django.db.models.sql.constants import ( from django.db.models.sql.query import Query, get_order_dir from django.db.transaction import TransactionManagementError from django.db.utils import DatabaseError, NotSupportedError -from django.utils.deprecation import ( - RemovedInDjango30Warning, RemovedInDjango31Warning, -) -from django.utils.inspect import func_supports_parameter +from django.utils.deprecation import RemovedInDjango31Warning FORCE = object() @@ -1015,20 +1011,7 @@ class SQLCompiler: backend_converters = self.connection.ops.get_db_converters(expression) field_converters = expression.get_db_converters(self.connection) if backend_converters or field_converters: - convs = [] - for conv in (backend_converters + field_converters): - if func_supports_parameter(conv, 'context'): - warnings.warn( - 'Remove the context parameter from %s.%s(). Support for it ' - 'will be removed in Django 3.0.' % ( - conv.__self__.__class__.__name__, - conv.__name__, - ), - RemovedInDjango30Warning, - ) - conv = functools.partial(conv, context={}) - convs.append(conv) - converters[i] = (convs, expression) + converters[i] = (backend_converters + field_converters, expression) return converters def apply_converters(self, rows, converters): diff --git a/docs/releases/3.0.txt b/docs/releases/3.0.txt index 9b2df51f6fe..b49708f675f 100644 --- a/docs/releases/3.0.txt +++ b/docs/releases/3.0.txt @@ -244,6 +244,9 @@ to remove usage of these features. * ``HttpRequest.xreadlines()`` is removed. +* Support for the ``context`` argument of ``Field.from_db_value()`` and + ``Expression.convert_value()`` is removed. + See :ref:`deprecated-features-2.1` for details on these changes, including how to remove usage of these features. diff --git a/tests/from_db_value/models.py b/tests/from_db_value/models.py index 3968a193d6f..5c5e5e1dbf3 100644 --- a/tests/from_db_value/models.py +++ b/tests/from_db_value/models.py @@ -28,12 +28,3 @@ class CashModel(models.Model): def __str__(self): return str(self.cash) - - -class CashFieldDeprecated(CashField): - def from_db_value(self, value, expression, connection, context): - return super().from_db_value(value, expression, connection) - - -class CashModelDeprecated(models.Model): - cash = CashFieldDeprecated() diff --git a/tests/from_db_value/test_deprecated.py b/tests/from_db_value/test_deprecated.py deleted file mode 100644 index 75539b3a8dd..00000000000 --- a/tests/from_db_value/test_deprecated.py +++ /dev/null @@ -1,17 +0,0 @@ -from django.test import TestCase -from django.utils.deprecation import RemovedInDjango30Warning - -from .models import Cash, CashModelDeprecated - - -class FromDBValueDeprecationTests(TestCase): - - def test_deprecation(self): - msg = ( - 'Remove the context parameter from CashFieldDeprecated.from_db_value(). ' - 'Support for it will be removed in Django 3.0.' - ) - CashModelDeprecated.objects.create(cash='12.50') - with self.assertWarnsMessage(RemovedInDjango30Warning, msg): - instance = CashModelDeprecated.objects.get() - self.assertIsInstance(instance.cash, Cash)