Refs #23919 -- Stopped inheriting from object to define new style classes.

This commit is contained in:
Simon Charette 2017-01-19 02:39:46 -05:00 committed by Claude Paroz
parent a556396339
commit cecc079168
293 changed files with 512 additions and 514 deletions

View File

@ -8,7 +8,7 @@ from django.utils.module_loading import module_has_submodule
MODELS_MODULE_NAME = 'models'
class AppConfig(object):
class AppConfig:
"""
Class representing a Django application and its configuration.
"""

View File

@ -10,7 +10,7 @@ from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured
from .config import AppConfig
class Apps(object):
class Apps:
"""
A registry that stores the configuration of installed applications.

View File

@ -97,7 +97,7 @@ class LazySettings(LazyObject):
return self._wrapped is not empty
class Settings(object):
class Settings:
def __init__(self, settings_module):
# update this dict from global settings (but only for ALL_CAPS settings)
for setting in dir(global_settings):
@ -150,7 +150,7 @@ class Settings(object):
}
class UserSettingsHolder(object):
class UserSettingsHolder:
"""
Holder for user configured settings.
"""

View File

@ -62,7 +62,7 @@ def check_dependencies(**kwargs):
return errors
class BaseModelAdminChecks(object):
class BaseModelAdminChecks:
def check(self, admin_obj, **kwargs):
errors = []

View File

@ -18,7 +18,7 @@ from django.utils.encoding import force_text
from django.utils.translation import ugettext_lazy as _
class ListFilter(object):
class ListFilter:
title = None # Human-readable title to appear in the right sidebar.
template = 'admin/filter.html'

View File

@ -31,7 +31,7 @@ class ActionForm(forms.Form):
checkbox = forms.CheckboxInput({'class': 'action-select'}, lambda value: False)
class AdminForm(object):
class AdminForm:
def __init__(self, form, fieldsets, prepopulated_fields, readonly_fields=None, model_admin=None):
self.form, self.fieldsets = form, fieldsets
self.prepopulated_fields = [{
@ -68,7 +68,7 @@ class AdminForm(object):
return media
class Fieldset(object):
class Fieldset:
def __init__(self, form, name=None, readonly_fields=(), fields=(), classes=(),
description=None, model_admin=None):
self.form = form
@ -95,7 +95,7 @@ class Fieldset(object):
yield Fieldline(self.form, field, self.readonly_fields, model_admin=self.model_admin)
class Fieldline(object):
class Fieldline:
def __init__(self, form, field, readonly_fields=None, model_admin=None):
self.form = form # A django.forms.Form instance
if not hasattr(field, "__iter__") or isinstance(field, str):
@ -126,7 +126,7 @@ class Fieldline(object):
)
class AdminField(object):
class AdminField:
def __init__(self, form, field, is_first):
self.field = form[field] # A django.forms.BoundField instance
self.is_first = is_first # Whether this field is first on the line
@ -155,7 +155,7 @@ class AdminField(object):
return mark_safe(self.field.errors.as_ul())
class AdminReadonlyField(object):
class AdminReadonlyField:
def __init__(self, form, field, is_first, model_admin=None):
# Make self.field look a little bit like a field. This means that
# {{ field.name }} must be a useful class name to identify the field.
@ -223,7 +223,7 @@ class AdminReadonlyField(object):
return conditional_escape(result_repr)
class InlineAdminFormSet(object):
class InlineAdminFormSet:
"""
A wrapper around an inline formset for use in the admin system.
"""

View File

@ -26,7 +26,7 @@ class NotRegistered(Exception):
pass
class AdminSite(object):
class AdminSite:
"""
An AdminSite object encapsulates an instance of the Django admin application, ready
to be hooked in to your URLconf. Models are registered with the AdminSite using the

View File

@ -34,7 +34,7 @@ IGNORED_PARAMS = (
ALL_VAR, ORDER_VAR, ORDER_TYPE_VAR, SEARCH_VAR, IS_POPUP_VAR, TO_FIELD_VAR)
class ChangeList(object):
class ChangeList:
def __init__(self, request, model, list_display, list_display_links,
list_filter, date_hierarchy, search_fields, list_select_related,
list_per_page, list_max_show_all, list_editable, model_admin):

View File

@ -4,7 +4,7 @@ from django.contrib.auth.models import Permission
UserModel = get_user_model()
class ModelBackend(object):
class ModelBackend:
"""
Authenticates against settings.AUTH_USER_MODEL.
"""

View File

@ -2,7 +2,7 @@
# the template system can understand.
class PermLookupDict(object):
class PermLookupDict:
def __init__(self, user, app_label):
self.user, self.app_label = user, app_label
@ -24,7 +24,7 @@ class PermLookupDict(object):
return type(self).__bool__(self)
class PermWrapper(object):
class PermWrapper:
def __init__(self, user):
self.user = user

View File

@ -162,7 +162,7 @@ def mask_hash(hash, show=6, char="*"):
return masked
class BasePasswordHasher(object):
class BasePasswordHasher:
"""
Abstract base class for password hashers

View File

@ -5,7 +5,7 @@ from django.core.exceptions import ImproperlyConfigured, PermissionDenied
from django.utils.encoding import force_text
class AccessMixin(object):
class AccessMixin:
"""
Abstract CBV mixin that gives access mixins the same customizable
functionality.

View File

@ -372,7 +372,7 @@ class User(AbstractUser):
swappable = 'AUTH_USER_MODEL'
class AnonymousUser(object):
class AnonymousUser:
id = None
pk = None
username = ''

View File

@ -90,7 +90,7 @@ def _password_validators_help_text_html(password_validators=None):
password_validators_help_text_html = lazy(_password_validators_help_text_html, str)
class MinimumLengthValidator(object):
class MinimumLengthValidator:
"""
Validate whether the password is of a minimum length.
"""
@ -117,7 +117,7 @@ class MinimumLengthValidator(object):
) % {'min_length': self.min_length}
class UserAttributeSimilarityValidator(object):
class UserAttributeSimilarityValidator:
"""
Validate whether the password is sufficiently different from the user's
attributes.
@ -159,7 +159,7 @@ class UserAttributeSimilarityValidator(object):
return _("Your password can't be too similar to your other personal information.")
class CommonPasswordValidator(object):
class CommonPasswordValidator:
"""
Validate whether the password is a common password.
@ -192,7 +192,7 @@ class CommonPasswordValidator(object):
return _("Your password can't be a commonly used password.")
class NumericPasswordValidator(object):
class NumericPasswordValidator:
"""
Validate whether the password is alphanumeric.
"""

View File

@ -5,7 +5,7 @@ from django.utils.crypto import constant_time_compare, salted_hmac
from django.utils.http import base36_to_int, int_to_base36
class PasswordResetTokenGenerator(object):
class PasswordResetTokenGenerator:
"""
Strategy object used to generate and check tokens for the password
reset mechanism.

View File

@ -31,7 +31,7 @@ from django.views.generic.edit import FormView
UserModel = get_user_model()
class SuccessURLAllowedHostsMixin(object):
class SuccessURLAllowedHostsMixin:
success_url_allowed_hosts = set()
def get_success_url_allowed_hosts(self):
@ -352,7 +352,7 @@ def password_reset_complete(request,
# prompts for a new password
# - PasswordResetCompleteView shows a success message for the above
class PasswordContextMixin(object):
class PasswordContextMixin:
extra_context = None
def get_context_data(self, **kwargs):

View File

@ -15,7 +15,7 @@ from django.utils.encoding import force_text
from django.utils.functional import cached_property
class GenericForeignKey(object):
class GenericForeignKey:
"""
Provide a generic many-to-one relation through the ``content_type`` and
``object_id`` fields.

View File

@ -1,4 +1,4 @@
class WKTAdapter(object):
class WKTAdapter:
"""
This provides an adaptor for Geometries sent to the
MySQL and Oracle database backends.

View File

@ -3,7 +3,7 @@ import re
from django.contrib.gis.db.models import aggregates
class BaseSpatialFeatures(object):
class BaseSpatialFeatures:
gis_enabled = True
# Does the database contain a SpatialRefSys model to store SRID information?

View File

@ -1,7 +1,7 @@
from django.contrib.gis import gdal
class SpatialRefSysMixin(object):
class SpatialRefSysMixin:
"""
The SpatialRefSysMixin is a class used by the database-dependent
SpatialRefSys objects to reduce redundant code.

View File

@ -1,4 +1,4 @@
class BaseSpatialOperations(object):
class BaseSpatialOperations:
"""
This module holds the base `BaseSpatialBackend` object, which is
instantiated by each spatial database backend with the features

View File

@ -8,7 +8,7 @@ from django.contrib.gis.db.backends.postgis.pgraster import to_pgraster
from django.contrib.gis.geometry.backend import Geometry
class PostGISAdapter(object):
class PostGISAdapter:
def __init__(self, obj, geography=False):
"""
Initialize on the spatial object.

View File

@ -4,7 +4,7 @@ backends.
"""
class SpatialOperator(object):
class SpatialOperator:
"""
Class encapsulating the behavior specific to a GIS operation (used by lookups).
"""

View File

@ -48,7 +48,7 @@ def get_srid_info(srid, connection):
return _srid_cache[alias][srid]
class GeoSelectFormatMixin(object):
class GeoSelectFormatMixin:
def select_format(self, compiler, sql, params):
"""
Returns the selection format string, depending on the requirements

View File

@ -100,7 +100,7 @@ class GeoFuncWithGeoParam(GeoFunc):
super(GeoFuncWithGeoParam, self).__init__(expression, GeomValue(geom), *expressions, **extra)
class SQLiteDecimalToFloatMixin(object):
class SQLiteDecimalToFloatMixin:
"""
By default, Decimal values are converted to str by the SQLite backend, which
is not acceptable by the GIS functions expecting numeric values.
@ -112,7 +112,7 @@ class SQLiteDecimalToFloatMixin(object):
return super(SQLiteDecimalToFloatMixin, self).as_sql(compiler, connection)
class OracleToleranceMixin(object):
class OracleToleranceMixin:
tolerance = 0.05
def as_oracle(self, compiler, connection):
@ -230,7 +230,7 @@ class Difference(OracleToleranceMixin, GeoFuncWithGeoParam):
arity = 2
class DistanceResultMixin(object):
class DistanceResultMixin:
def source_is_geography(self):
return self.get_source_fields()[0].geography and self.srid == 4326

View File

@ -9,7 +9,7 @@ from django.contrib.gis.geometry.backend import Geometry
from django.contrib.gis.measure import Area, Distance
class BaseField(object):
class BaseField:
empty_strings_allowed = True
def get_db_converters(self, connection):

View File

@ -2,7 +2,7 @@ from django.contrib.syndication.views import Feed as BaseFeed
from django.utils.feedgenerator import Atom1Feed, Rss201rev2Feed
class GeoFeedMixin(object):
class GeoFeedMixin:
"""
This mixin provides the necessary routines for SyndicationFeed subclasses
to produce simple GeoRSS or W3C Geo elements.

View File

@ -27,7 +27,7 @@ class OGREnvelope(Structure):
]
class Envelope(object):
class Envelope:
"""
The Envelope object is a C structure that contains the minimum and
maximum X, Y coordinates for a rectangle bounding box. The naming

View File

@ -1,7 +1,7 @@
from django.contrib.gis.gdal.error import GDALException
class OGRGeomType(object):
class OGRGeomType:
"Encapsulates OGR Geometry Types."
wkb25bit = -2147483648

View File

@ -21,7 +21,7 @@ class GeoIP2Exception(Exception):
pass
class GeoIP2(object):
class GeoIP2:
# The flags for GeoIP memory caching.
# Try MODE_MMAP_EXT, MODE_MMAP, MODE_FILE in that order.
MODE_AUTO = 0

View File

@ -656,7 +656,7 @@ class GEOSGeometry(GEOSBase, ListMixin):
return GEOSGeometry(capi.geom_clone(self.ptr), srid=self.srid)
class LinearGeometryMixin(object):
class LinearGeometryMixin:
"""
Used for LineString and MultiLineString.
"""

View File

@ -139,7 +139,7 @@ def get_pointer_arr(n):
lgeos = SimpleLazyObject(load_geos)
class GEOSFuncFactory(object):
class GEOSFuncFactory:
"""
Lazy loading of GEOS functions.
"""

View File

@ -12,7 +12,7 @@ from functools import total_ordering
@total_ordering
class ListMixin(object):
class ListMixin:
"""
A base class which provides complete list interface.
Derived classes must call ListMixin's __init__() function

View File

@ -28,7 +28,7 @@ class GEOSContext(threading.local):
thread_context = GEOSContext()
class GEOSFunc(object):
class GEOSFunc:
"""
Class that serves as a wrapper for GEOS C Functions, and will
use thread-safe function variants when available.

View File

@ -49,7 +49,7 @@ def pretty_name(obj):
@total_ordering
class MeasureBase(object):
class MeasureBase:
STANDARD_UNIT = None
ALIAS = {}
UNITS = {}

View File

@ -1,7 +1,7 @@
from ctypes import c_void_p
class CPointerBase(object):
class CPointerBase:
"""
Base class for objects that have a pointer access property
that controls access to the underlying C pointer.

View File

@ -65,6 +65,6 @@ class Serializer(JSONSerializer):
super(Serializer, self).handle_field(obj, field)
class Deserializer(object):
class Deserializer:
def __init__(self, *args, **kwargs):
raise SerializerDoesNotExist("geojson is a serialization-only serializer")

View File

@ -45,7 +45,7 @@ class MissingForeignKey(LayerMapError):
pass
class LayerMapping(object):
class LayerMapping:
"A class that maps OGR Layers to GeoDjango Models."
# Acceptable 'base' types for a multi-geometry type.

View File

@ -5,7 +5,7 @@ from django.utils.encoding import force_text
LEVEL_TAGS = utils.get_level_tags()
class Message(object):
class Message:
"""
Represents an actual message that can be stored in any of the supported
storage classes (typically session- or cookie-based) and rendered in a view
@ -51,7 +51,7 @@ class Message(object):
return force_text(LEVEL_TAGS.get(self.level, ''), strings_only=True)
class BaseStorage(object):
class BaseStorage:
"""
This is the base backend for temporary message storage.

View File

@ -1,7 +1,7 @@
from django.contrib import messages
class SuccessMessageMixin(object):
class SuccessMessageMixin:
"""
Adds a success message on successful form submission.
"""

View File

@ -264,7 +264,7 @@ class IndexTransform(Transform):
return self.base_field
class IndexTransformFactory(object):
class IndexTransformFactory:
def __init__(self, index, base_field):
self.index = index
@ -286,7 +286,7 @@ class SliceTransform(Transform):
return '%s[%s:%s]' % (lhs, self.start, self.end), params
class SliceTransformFactory(object):
class SliceTransformFactory:
def __init__(self, start, end):
self.start = start

View File

@ -88,7 +88,7 @@ class KeyTransform(Transform):
return "(%s -> '%s')" % (lhs, self.key_name), params
class KeyTransformFactory(object):
class KeyTransformFactory:
def __init__(self, key_name):
self.key_name = key_name

View File

@ -118,7 +118,7 @@ class KeyTextTransform(KeyTransform):
_output_field = TextField()
class KeyTransformTextLookupMixin(object):
class KeyTransformTextLookupMixin:
"""
Mixin for combining with a lookup expecting a text lhs from a JSONField
key lookup. Make use of the ->> operator instead of casting key values to
@ -174,7 +174,7 @@ KeyTransform.register_lookup(KeyTransformRegex)
KeyTransform.register_lookup(KeyTransformIRegex)
class KeyTransformFactory(object):
class KeyTransformFactory:
def __init__(self, key_name):
self.key_name = key_name

View File

@ -1,3 +1,3 @@
class AttributeSetter(object):
class AttributeSetter:
def __init__(self, name, value):
setattr(self, name, value)

View File

@ -33,7 +33,7 @@ class SearchQueryField(Field):
return 'tsquery'
class SearchVectorCombinable(object):
class SearchVectorCombinable:
ADD = '||'
def _combine(self, other, connector, reversed, node=None):
@ -92,7 +92,7 @@ class CombinedSearchVector(SearchVectorCombinable, CombinedExpression):
super(CombinedSearchVector, self).__init__(lhs, connector, rhs, output_field)
class SearchQueryCombinable(object):
class SearchQueryCombinable:
BITAND = '&&'
BITOR = '||'

View File

@ -24,7 +24,7 @@ class ArrayMinLengthValidator(MinLengthValidator):
@deconstructible
class KeysValidator(object):
class KeysValidator:
"""A validator designed for HStore to require/restrict keys."""
messages = {

View File

@ -33,7 +33,7 @@ class UpdateError(Exception):
pass
class SessionBase(object):
class SessionBase:
"""
Base class for all Session classes.
"""

View File

@ -3,7 +3,7 @@ import pickle
from django.core.signing import JSONSerializer as BaseJSONSerializer
class PickleSerializer(object):
class PickleSerializer:
"""
Simple wrapper around pickle to be used in signing.dumps and
signing.loads.

View File

@ -50,7 +50,7 @@ def _get_sitemap_full_url(sitemap_url):
return 'http://%s%s' % (current_site.domain, sitemap_url)
class Sitemap(object):
class Sitemap:
# This limit is defined by Google. See the index documentation at
# http://www.sitemaps.org/protocol.html#index.
limit = 50000

View File

@ -1,4 +1,4 @@
class RequestSite(object):
class RequestSite:
"""
A class that shares the primary interface of Site (i.e., it has
``domain`` and ``name`` attributes) but gets its data from a Django

View File

@ -17,7 +17,7 @@ from django.utils.module_loading import import_string
searched_locations = []
class BaseFinder(object):
class BaseFinder:
"""
A base file finder to be used for custom staticfiles finder classes.
"""

View File

@ -47,7 +47,7 @@ class StaticFilesStorage(FileSystemStorage):
return super(StaticFilesStorage, self).path(name)
class HashedFilesMixin(object):
class HashedFilesMixin:
default_template = """url("%s")"""
max_post_process_passes = 5
patterns = (
@ -434,7 +434,7 @@ class ManifestFilesMixin(HashedFilesMixin):
return urlunsplit(unparsed_name)
class _MappingCache(object):
class _MappingCache:
"""
A small dict-like wrapper for a given cache backend instance.
"""

View File

@ -26,7 +26,7 @@ class FeedDoesNotExist(ObjectDoesNotExist):
pass
class Feed(object):
class Feed:
feed_type = feedgenerator.DefaultFeed
title_template = None
description_template = None

View File

@ -55,7 +55,7 @@ def _create_cache(backend, **kwargs):
return backend_cls(location, params)
class CacheHandler(object):
class CacheHandler:
"""
A Cache Handler to manage access to Cache instances.
@ -88,7 +88,7 @@ class CacheHandler(object):
caches = CacheHandler()
class DefaultCacheProxy(object):
class DefaultCacheProxy:
"""
Proxy access to the default Cache object's attributes.

View File

@ -47,7 +47,7 @@ def get_key_func(key_func):
return default_key_func
class BaseCache(object):
class BaseCache:
def __init__(self, params):
timeout = params.get('timeout', params.get('TIMEOUT', 300))
if timeout is not None:

View File

@ -10,7 +10,7 @@ from django.utils import timezone
from django.utils.encoding import force_bytes
class Options(object):
class Options:
"""A class that will quack like a Django model _meta class.
This allows cache operations to be controlled by the router
@ -33,7 +33,7 @@ class BaseDatabaseCache(BaseCache):
BaseCache.__init__(self, params)
self._table = table
class CacheEntry(object):
class CacheEntry:
_meta = Options(table)
self.cache_model_class = CacheEntry

View File

@ -8,7 +8,7 @@ ERROR = 40
CRITICAL = 50
class CheckMessage(object):
class CheckMessage:
def __init__(self, level, msg, hint=None, obj=None, id=None):
assert isinstance(level, int), "The first argument should be level."

View File

@ -3,7 +3,7 @@ from itertools import chain
from django.utils.itercompat import is_iterable
class Tags(object):
class Tags:
"""
Built-in tags for internal checks.
"""
@ -18,7 +18,7 @@ class Tags(object):
urls = 'urls'
class CheckRegistry(object):
class CheckRegistry:
def __init__(self):
self.registered_checks = []

View File

@ -20,7 +20,7 @@ from django.utils.text import get_valid_filename
__all__ = ('Storage', 'FileSystemStorage', 'DefaultStorage', 'default_storage')
class Storage(object):
class Storage:
"""
A base storage class, providing some default behaviors that all other
storage systems can inherit or override, as necessary.

View File

@ -58,7 +58,7 @@ class StopFutureHandlers(UploadFileException):
pass
class FileUploadHandler(object):
class FileUploadHandler:
"""
Base class for streaming upload handlers.
"""

View File

@ -1,4 +1,4 @@
class FileProxyMixin(object):
class FileProxyMixin:
"""
A mixin class used to forward file methods to an underlaying file
object. The internal file object has to be called "file"::

View File

@ -12,7 +12,7 @@ from .exception import convert_exception_to_response, get_exception_response
logger = logging.getLogger('django.request')
class BaseHandler(object):
class BaseHandler:
def __init__(self):
self._request_middleware = None

View File

@ -19,7 +19,7 @@ ISO_8859_1, UTF_8 = str('iso-8859-1'), str('utf-8')
_slashes_re = re.compile(br'/+')
class LimitedStream(object):
class LimitedStream:
'''
LimitedStream wraps another stream in order to not allow reading from it
past specified amount of bytes.

View File

@ -1,7 +1,7 @@
"""Base email backend class."""
class BaseEmailBackend(object):
class BaseEmailBackend:
"""
Base class for email backend implementations.

View File

@ -223,7 +223,7 @@ class SafeMIMEMultipart(MIMEMixin, MIMEMultipart):
MIMEMultipart.__setitem__(self, name, val)
class EmailMessage(object):
class EmailMessage:
"""
A container for email information.
"""

View File

@ -7,7 +7,7 @@ import socket
# Cache the hostname, but do it lazily: socket.getfqdn() can take a couple of
# seconds, which slows down the restart of the server.
class CachedDnsName(object):
class CachedDnsName:
def __str__(self):
return self.get_fqdn()

View File

@ -129,7 +129,7 @@ def call_command(command_name, *args, **options):
return command.execute(*args, **defaults)
class ManagementUtility(object):
class ManagementUtility:
"""
Encapsulates the logic of the django-admin and manage.py utilities.

View File

@ -73,7 +73,7 @@ def handle_default_options(options):
sys.path.insert(0, options.pythonpath)
class OutputWrapper(object):
class OutputWrapper:
"""
Wrapper around stdout/stderr
"""
@ -107,7 +107,7 @@ class OutputWrapper(object):
self._out.write(force_str(style_func(msg)))
class BaseCommand(object):
class BaseCommand:
"""
The base class from which all management commands ultimately
derive.

View File

@ -24,7 +24,7 @@ def supports_color():
return True
class Style(object):
class Style:
pass

View File

@ -36,7 +36,7 @@ def check_programs(*programs):
@total_ordering
class TranslatableFile(object):
class TranslatableFile:
def __init__(self, dirpath, file_name, locale_dir):
self.file = file_name
self.dirpath = dirpath
@ -59,7 +59,7 @@ class TranslatableFile(object):
return os.path.join(self.dirpath, self.file)
class BuildFile(object):
class BuildFile:
"""
Represents the state of a translatable file during the build process.
"""

View File

@ -22,7 +22,7 @@ class EmptyPage(InvalidPage):
pass
class Paginator(object):
class Paginator:
def __init__(self, object_list, per_page, orphans=0,
allow_empty_first_page=True):

View File

@ -33,7 +33,7 @@ BUILTIN_SERIALIZERS = {
_serializers = {}
class BadSerializer(object):
class BadSerializer:
"""
Stub serializer to hold exception raised during registration
@ -71,7 +71,7 @@ def register_serializer(format, serializer_module, serializers=None):
except ImportError as exc:
bad_serializer = BadSerializer(exc)
module = type('BadSerializerModule', (object,), {
module = type('BadSerializerModule', (), {
'Deserializer': bad_serializer,
'Serializer': bad_serializer,
})

View File

@ -28,7 +28,7 @@ class DeserializationError(Exception):
return cls("%s: (%s:pk=%s) field_value was '%s'" % (original_exc, model, fk, field_value))
class ProgressBar(object):
class ProgressBar:
progress_width = 75
def __init__(self, output, total_count):
@ -51,7 +51,7 @@ class ProgressBar(object):
self.output.flush()
class Serializer(object):
class Serializer:
"""
Abstract serializer base class.
"""
@ -182,7 +182,7 @@ class Deserializer:
raise NotImplementedError('subclasses of Deserializer must provide a __next__() method')
class DeserializedObject(object):
class DeserializedObject:
"""
A deserialized model.

View File

@ -60,7 +60,7 @@ def is_broken_pipe_error():
return issubclass(exc_type, socket.error) and exc_value.args[0] == 32
class WSGIServer(simple_server.WSGIServer, object):
class WSGIServer(simple_server.WSGIServer):
"""BaseHTTPServer that implements the Python WSGI protocol"""
request_queue_size = 10
@ -84,14 +84,14 @@ class WSGIServer(simple_server.WSGIServer, object):
# Inheriting from object required on Python 2.
class ServerHandler(simple_server.ServerHandler, object):
class ServerHandler(simple_server.ServerHandler):
def handle_error(self):
# Ignore broken pipe errors, otherwise pass on
if not is_broken_pipe_error():
super(ServerHandler, self).handle_error()
class WSGIRequestHandler(simple_server.WSGIRequestHandler, object):
class WSGIRequestHandler(simple_server.WSGIRequestHandler):
def address_string(self):
# Short-circuit parent method to not call socket.getfqdn
return self.client_address[0]

View File

@ -82,7 +82,7 @@ def get_cookie_signer(salt='django.core.signing.get_cookie_signer'):
return Signer(b'django.http.cookies' + key, salt=salt)
class JSONSerializer(object):
class JSONSerializer:
"""
Simple wrapper around json to be used in signing.dumps and
signing.loads.
@ -147,7 +147,7 @@ def loads(s, key=None, salt='django.core.signing', serializer=JSONSerializer, ma
return serializer().loads(data)
class Signer(object):
class Signer:
def __init__(self, key=None, sep=':', salt=None):
# Use of native strings in all versions of Python

View File

@ -26,7 +26,7 @@ def _lazy_re_compile(regex, flags=0):
@deconstructible
class RegexValidator(object):
class RegexValidator:
regex = ''
message = _('Enter a valid value.')
code = 'invalid'
@ -162,7 +162,7 @@ def validate_integer(value):
@deconstructible
class EmailValidator(object):
class EmailValidator:
message = _('Enter a valid email address.')
code = 'invalid'
user_regex = _lazy_re_compile(
@ -305,7 +305,7 @@ validate_comma_separated_integer_list = int_list_validator(
@deconstructible
class BaseValidator(object):
class BaseValidator:
message = _('Ensure this value is %(limit_value)s (it is %(show_value)s).')
code = 'limit_value'
@ -384,7 +384,7 @@ class MaxLengthValidator(BaseValidator):
@deconstructible
class DecimalValidator(object):
class DecimalValidator:
"""
Validate that the input does not exceed the maximum number of digits
expected, otherwise raise ValidationError.
@ -453,7 +453,7 @@ class DecimalValidator(object):
@deconstructible
class FileExtensionValidator(object):
class FileExtensionValidator:
message = _(
"File extension '%(extension)s' is not allowed. "
"Allowed extensions are: '%(allowed_extensions)s'."

View File

@ -23,7 +23,7 @@ router = ConnectionRouter()
# that the database backends care about.
# We load all these up for backwards compatibility, you should use
# connections['default'] instead.
class DefaultConnectionProxy(object):
class DefaultConnectionProxy:
"""
Proxy for accessing the default DatabaseWrapper object's attributes. If you
need to access the DatabaseWrapper object itself, use

View File

@ -21,7 +21,7 @@ from django.utils.functional import cached_property
NO_DB_ALIAS = '__no_db__'
class BaseDatabaseWrapper(object):
class BaseDatabaseWrapper:
"""
Represents a database connection.
"""

View File

@ -1,4 +1,4 @@
class BaseDatabaseClient(object):
class BaseDatabaseClient:
"""
This class encapsulates all backend-specific methods for opening a
client shell.

View File

@ -11,7 +11,7 @@ from django.db import router
TEST_DATABASE_PREFIX = 'test_'
class BaseDatabaseCreation(object):
class BaseDatabaseCreation:
"""
This class encapsulates all backend-specific differences that pertain to
creation and destruction of the test database.

View File

@ -3,7 +3,7 @@ from django.db.utils import ProgrammingError
from django.utils.functional import cached_property
class BaseDatabaseFeatures(object):
class BaseDatabaseFeatures:
gis_enabled = False
allows_group_by_pk = False
allows_group_by_selected_pks = False

View File

@ -7,7 +7,7 @@ TableInfo = namedtuple('TableInfo', ['name', 'type'])
FieldInfo = namedtuple('FieldInfo', 'name type_code display_size internal_size precision scale null_ok default')
class BaseDatabaseIntrospection(object):
class BaseDatabaseIntrospection:
"""
This class encapsulates all backend-specific introspection utilities
"""

View File

@ -10,7 +10,7 @@ from django.utils.dateparse import parse_duration
from django.utils.encoding import force_text
class BaseDatabaseOperations(object):
class BaseDatabaseOperations:
"""
This class encapsulates all backend-specific differences, such as the way
a backend performs ordering or calculates the ID of a recently-inserted

View File

@ -19,7 +19,7 @@ def _related_non_m2m_objects(old_field, new_field):
)
class BaseDatabaseSchemaEditor(object):
class BaseDatabaseSchemaEditor:
"""
This class (and its subclasses) are responsible for emitting schema-changing
statements to the databases - model creation/removal/alteration, field

View File

@ -1,4 +1,4 @@
class BaseDatabaseValidation(object):
class BaseDatabaseValidation:
"""
This class encapsulates all backend-specific validation.
"""

View File

@ -69,7 +69,7 @@ server_version_re = re.compile(r'(\d{1,2})\.(\d{1,2})\.(\d{1,2})')
# standard backend_utils.CursorDebugWrapper can be used. Also, using sql_mode
# TRADITIONAL will automatically cause most warnings to be treated as errors.
class CursorWrapper(object):
class CursorWrapper:
"""
A thin wrapper around MySQLdb's normal cursor class so that we can catch
particular exception instances and reraise them with the right types.

View File

@ -59,7 +59,7 @@ from .schema import DatabaseSchemaEditor # NOQA isort:skip
from .utils import Oracle_datetime # NOQA isort:skip
class _UninitializedOperatorsDescriptor(object):
class _UninitializedOperatorsDescriptor:
def __get__(self, instance, cls=None):
# If connection.operators is looked up before a connection has been
@ -306,7 +306,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
return None
class OracleParam(object):
class OracleParam:
"""
Wrapper object for formatting parameters for Oracle. If the string
representation of the value is large enough (greater than 4000 characters)
@ -351,7 +351,7 @@ class OracleParam(object):
self.input_size = None
class VariableWrapper(object):
class VariableWrapper:
"""
An adapter class for cursor variables that prevents the wrapped object
from being converted into a string when used to instantiate an OracleParam.
@ -375,7 +375,7 @@ class VariableWrapper(object):
setattr(self.var, key, value)
class FormatStylePlaceholderCursor(object):
class FormatStylePlaceholderCursor:
"""
Django uses "format" (e.g. '%s') style placeholders, but Oracle uses ":var"
style. This fixes it -- but note that if you want to use a literal "%s" in

View File

@ -3,7 +3,7 @@ import datetime
from .base import Database
class InsertIdVar(object):
class InsertIdVar:
"""
A late-binding cursor variable that can be passed to Cursor.execute
as a parameter, in order to receive the id of the row created by an

View File

@ -18,7 +18,7 @@ def get_field_size(name):
# This light wrapper "fakes" a dictionary interface, because some SQLite data
# types include variables in them -- e.g. "varchar(30)" -- and can't be matched
# as a simple dictionary lookup.
class FlexibleFieldLookupDict(object):
class FlexibleFieldLookupDict:
# Maps SQL types to Django Field types. Some of the SQL types have multiple
# entries here because SQLite allows for anything and doesn't normalize the
# field type; it uses whatever was given.

View File

@ -11,7 +11,7 @@ from django.utils.timezone import utc
logger = logging.getLogger('django.db.backends')
class CursorWrapper(object):
class CursorWrapper:
def __init__(self, cursor, db):
self.cursor = cursor
self.db = db

View File

@ -16,7 +16,7 @@ from django.db.migrations.utils import (
from .topological_sort import stable_topological_sort
class MigrationAutodetector(object):
class MigrationAutodetector:
"""
Takes a pair of ProjectStates, and compares them to see what the
first would need doing to make it match the second (the second

View File

@ -7,7 +7,7 @@ from .recorder import MigrationRecorder
from .state import ProjectState
class MigrationExecutor(object):
class MigrationExecutor:
"""
End-to-end migration execution - loads migrations, and runs them
up or down to a specified set of targets.

View File

@ -18,7 +18,7 @@ RECURSION_DEPTH_WARNING = (
@total_ordering
class Node(object):
class Node:
"""
A single node in the migration graph. Contains direct links to adjacent
nodes in either direction.
@ -100,7 +100,7 @@ class DummyNode(Node):
raise NodeNotFoundError(self.error_message, self.key, origin=self.origin)
class MigrationGraph(object):
class MigrationGraph:
"""
Represents the digraph of all migrations in a project.

View File

@ -16,7 +16,7 @@ from .exceptions import (
MIGRATIONS_MODULE_NAME = 'migrations'
class MigrationLoader(object):
class MigrationLoader:
"""
Loads migration files from disk, and their status from the database.

View File

@ -3,7 +3,7 @@ from django.db.transaction import atomic
from .exceptions import IrreversibleError
class Migration(object):
class Migration:
"""
The base class for all migrations.

View File

@ -1,7 +1,7 @@
from django.db import router
class Operation(object):
class Operation:
"""
Base class for migration operations.

View File

@ -1,4 +1,4 @@
class MigrationOptimizer(object):
class MigrationOptimizer:
"""
Powers the optimization process, where you provide a list of Operations
and you are returned a list of equal or shorter length - operations

View File

@ -9,7 +9,7 @@ from django.utils import datetime_safe, timezone
from .loader import MigrationLoader
class MigrationQuestioner(object):
class MigrationQuestioner:
"""
Gives the autodetector responses to questions it might have.
This base class has a built-in noninteractive mode, but the

View File

@ -6,7 +6,7 @@ from django.utils.timezone import now
from .exceptions import MigrationSchemaMissing
class MigrationRecorder(object):
class MigrationRecorder:
"""
Deals with storing migration records in the database.

View File

@ -24,7 +24,7 @@ except ImportError:
enum = None
class BaseSerializer(object):
class BaseSerializer:
def __init__(self, value):
self.value = value

Some files were not shown because too many files have changed in this diff Show More