Use collections.abc.Iterable instead of collections.Iterable

The latter is going to be removed after Python 3.8
This commit is contained in:
Swen Kooij 2019-08-14 08:57:05 +03:00
parent 946e9a67c4
commit 3de1492a58
3 changed files with 27 additions and 3 deletions

View File

@ -1,7 +1,8 @@
import deprecation import deprecation
import collections
from typing import Optional from typing import Optional
from collections.abc import Iterable
from django.conf import settings from django.conf import settings
from django.utils import translation from django.utils import translation
@ -97,7 +98,7 @@ class LocalizedValue(dict):
lang_value = value.get(lang_code, self.default_value) lang_value = value.get(lang_code, self.default_value)
self.set(lang_code, lang_value) self.set(lang_code, lang_value)
elif isinstance(value, collections.Iterable): elif isinstance(value, Iterable):
for val in value: for val in value:
self._interpret_value(val) self._interpret_value(val)

View File

@ -1,2 +1,2 @@
django-postgres-extra==1.21a9 django-postgres-extra==1.22
deprecation==2.0.3 deprecation==2.0.3

View File

@ -24,10 +24,33 @@ INSTALLED_APPS = (
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.contenttypes',
'django.contrib.admin', 'django.contrib.admin',
'django.contrib.messages',
'localized_fields', 'localized_fields',
'tests', 'tests',
) )
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]
MIDDLEWARE = [
'django.contrib.messages.middleware.MessageMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
]
# set to a lower number than the default, since # set to a lower number than the default, since
# we want the tests to be fast, default is 100 # we want the tests to be fast, default is 100
LOCALIZED_FIELDS_MAX_RETRIES = 3 LOCALIZED_FIELDS_MAX_RETRIES = 3