Skip to content

Commit

Permalink
Removed some outdated backwards compatibility imports and misleading …
Browse files Browse the repository at this point in the history
…comments.

EmptyResultSet moved in 46509cf.
FieldDoesNotExist moved in 8958170.
BoundField and pretty_name moved in 8550161.
EMPTY_VALUES moved in 471596f.
BaseRunserverCommand moved in 5c53e30.
  • Loading branch information
atombrella authored and felixxm committed Sep 24, 2019
1 parent aad46ee commit 129583a
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 38 deletions.
4 changes: 0 additions & 4 deletions django/core/management/commands/runserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,3 @@ def inner_run(self, *args, **options):
if shutdown_message:
self.stdout.write(shutdown_message)
sys.exit(0)


# Kept for backward compatibility
BaseRunserverCommand = Command
14 changes: 5 additions & 9 deletions django/db/models/fields/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
from django.apps import apps
from django.conf import settings
from django.core import checks, exceptions, validators
# When the _meta object was formalized, this exception was moved to
# django.core.exceptions. It is retained here for backwards compatibility
# purposes.
from django.core.exceptions import FieldDoesNotExist # NOQA
from django.db import connection, connections, router
from django.db.models.constants import LOOKUP_SEP
from django.db.models.query_utils import DeferredAttribute, RegisterLookupMixin
Expand All @@ -35,11 +31,11 @@
'AutoField', 'BLANK_CHOICE_DASH', 'BigAutoField', 'BigIntegerField',
'BinaryField', 'BooleanField', 'CharField', 'CommaSeparatedIntegerField',
'DateField', 'DateTimeField', 'DecimalField', 'DurationField',
'EmailField', 'Empty', 'Field', 'FieldDoesNotExist', 'FilePathField',
'FloatField', 'GenericIPAddressField', 'IPAddressField', 'IntegerField',
'NOT_PROVIDED', 'NullBooleanField', 'PositiveIntegerField',
'PositiveSmallIntegerField', 'SlugField', 'SmallAutoField',
'SmallIntegerField', 'TextField', 'TimeField', 'URLField', 'UUIDField',
'EmailField', 'Empty', 'Field', 'FilePathField', 'FloatField',
'GenericIPAddressField', 'IPAddressField', 'IntegerField', 'NOT_PROVIDED',
'NullBooleanField', 'PositiveIntegerField', 'PositiveSmallIntegerField',
'SlugField', 'SmallAutoField', 'SmallIntegerField', 'TextField',
'TimeField', 'URLField', 'UUIDField',
]


Expand Down
3 changes: 0 additions & 3 deletions django/db/models/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
# The maximum number of items to display in a QuerySet.__repr__
REPR_OUTPUT_SIZE = 20

# Pull into this namespace for backwards compatibility.
EmptyResultSet = sql.EmptyResultSet


class BaseIterable:
def __init__(self, queryset, chunked_fetch=False, chunk_size=GET_ITERATOR_CHUNK_SIZE):
Expand Down
3 changes: 1 addition & 2 deletions django/db/models/sql/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from django.core.exceptions import EmptyResultSet
from django.db.models.sql.query import * # NOQA
from django.db.models.sql.query import Query
from django.db.models.sql.subqueries import * # NOQA
from django.db.models.sql.where import AND, OR

__all__ = ['Query', 'AND', 'OR', 'EmptyResultSet']
__all__ = ['Query', 'AND', 'OR']
2 changes: 0 additions & 2 deletions django/db/models/sql/datastructures.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
Useful auxiliary data structures for query construction. Not useful outside
the SQL domain.
"""
# for backwards-compatibility in Django 1.11
from django.core.exceptions import EmptyResultSet # NOQA: F401
from django.db.models.sql.constants import INNER, LOUTER


Expand Down
2 changes: 0 additions & 2 deletions django/forms/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

from django.core import validators
from django.core.exceptions import ValidationError
# Provide this import for backwards compatibility.
from django.core.validators import EMPTY_VALUES # NOQA
from django.forms.boundfield import BoundField
from django.forms.utils import from_current_timezone, to_current_timezone
from django.forms.widgets import (
Expand Down
5 changes: 1 addition & 4 deletions django/forms/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
import copy

from django.core.exceptions import NON_FIELD_ERRORS, ValidationError
# BoundField is imported for backwards compatibility in Django 1.9
from django.forms.boundfield import BoundField # NOQA
from django.forms.fields import Field, FileField
# pretty_name is imported for backwards compatibility in Django 1.9
from django.forms.utils import ErrorDict, ErrorList, pretty_name # NOQA
from django.forms.utils import ErrorDict, ErrorList
from django.forms.widgets import Media, MediaDefiningClass
from django.utils.datastructures import MultiValueDict
from django.utils.functional import cached_property
Expand Down
2 changes: 1 addition & 1 deletion django/forms/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from collections import UserList

from django.conf import settings
from django.core.exceptions import ValidationError # backwards compatibility
from django.core.exceptions import ValidationError
from django.utils import timezone
from django.utils.html import escape, format_html, format_html_join, html_safe
from django.utils.translation import gettext_lazy as _
Expand Down
4 changes: 2 additions & 2 deletions django/template/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@

# Public exceptions
from .base import VariableDoesNotExist # NOQA isort:skip
from .context import ContextPopException # NOQA isort:skip
from .context import Context, ContextPopException, RequestContext # NOQA isort:skip
from .exceptions import TemplateDoesNotExist, TemplateSyntaxError # NOQA isort:skip

# Template parts
from .base import ( # NOQA isort:skip
Context, Node, NodeList, Origin, RequestContext, Template, Variable,
Node, NodeList, Origin, Template, Variable,
)

# Library management
Expand Down
4 changes: 1 addition & 3 deletions django/template/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@
from enum import Enum
from inspect import getcallargs, getfullargspec, unwrap

from django.template.context import ( # NOQA: imported for backwards compatibility
BaseContext, Context, ContextPopException, RequestContext,
)
from django.template.context import BaseContext
from django.utils.formats import localize
from django.utils.html import conditional_escape, escape
from django.utils.safestring import SafeData, mark_safe
Expand Down
7 changes: 4 additions & 3 deletions django/template/defaulttags.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
from .base import (
BLOCK_TAG_END, BLOCK_TAG_START, COMMENT_TAG_END, COMMENT_TAG_START,
FILTER_SEPARATOR, SINGLE_BRACE_END, SINGLE_BRACE_START,
VARIABLE_ATTRIBUTE_SEPARATOR, VARIABLE_TAG_END, VARIABLE_TAG_START,
Context, Node, NodeList, TemplateSyntaxError, VariableDoesNotExist,
kwarg_re, render_value_in_context, token_kwargs,
VARIABLE_ATTRIBUTE_SEPARATOR, VARIABLE_TAG_END, VARIABLE_TAG_START, Node,
NodeList, TemplateSyntaxError, VariableDoesNotExist, kwarg_re,
render_value_in_context, token_kwargs,
)
from .context import Context
from .defaultfilters import date
from .library import Library
from .smartif import IfParser, Literal
Expand Down
4 changes: 2 additions & 2 deletions django/template/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from django.utils.functional import cached_property
from django.utils.module_loading import import_string

from .base import Context, Template
from .context import _builtin_context_processors
from .base import Template
from .context import Context, _builtin_context_processors
from .exceptions import TemplateDoesNotExist
from .library import import_library

Expand Down
13 changes: 13 additions & 0 deletions docs/releases/3.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,19 @@ Miscellaneous
Django 3.1, the first request to any previously cached template fragment will
be a cache miss.

* The compatibility imports of ``django.core.exceptions.EmptyResultSet`` in
``django.db.models.query``, ``django.db.models.sql``, and
``django.db.models.sql.datastructures`` are removed.

* The compatibility import of ``django.core.exceptions.FieldDoesNotExist`` in
``django.db.models.fields`` is removed.

* The compatibility imports of ``django.forms.utils.pretty_name()`` and
``django.forms.boundfield.BoundField`` in ``django.forms.forms`` are removed.

* The compatibility imports of ``Context``, ``ContextPopException``, and
``RequestContext`` in ``django.template.base`` are removed.

.. _deprecated-features-3.1:

Features deprecated in 3.1
Expand Down
3 changes: 2 additions & 1 deletion tests/template_tests/syntax_tests/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.template.base import Context, TemplateSyntaxError
from django.template.base import TemplateSyntaxError
from django.template.context import Context
from django.test import SimpleTestCase

from ..utils import SilentAttrClass, SilentGetItemClass, SomeClass, setup
Expand Down

0 comments on commit 129583a

Please sign in to comment.