diff options
| author | Sergey Fedoseev <fedoseev.sergey@gmail.com> | 2017-08-23 20:40:17 +0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-08-23 11:40:17 -0400 |
| commit | fac74b84a3abd92f1a49070f31ec7c8c0df8b698 (patch) | |
| tree | 30876a694bcab6a5669c66d03406b55b218438d5 | |
| parent | 939d923e8ee1144b76fb35ebba6d818701cd8566 (diff) | |
Used OrderedDict.fromkeys() to initialize OrderedDict with None values.
| -rw-r--r-- | django/contrib/admin/options.py | 4 | ||||
| -rw-r--r-- | django/core/management/commands/dumpdata.py | 4 | ||||
| -rw-r--r-- | django/utils/datastructures.py | 2 |
3 files changed, 5 insertions, 5 deletions
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index 0e275bc25a..a88c867d85 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -627,8 +627,8 @@ class ModelAdmin(BaseModelAdmin): exclude = exclude or None # Remove declared form fields which are in readonly_fields. - new_attrs = OrderedDict( - (f, None) for f in readonly_fields + new_attrs = OrderedDict.fromkeys( + f for f in readonly_fields if f in self.form.declared_fields ) form = type(self.form.__name__, (self.form,), new_attrs) diff --git a/django/core/management/commands/dumpdata.py b/django/core/management/commands/dumpdata.py index 11b6c8c244..b246cee238 100644 --- a/django/core/management/commands/dumpdata.py +++ b/django/core/management/commands/dumpdata.py @@ -87,8 +87,8 @@ class Command(BaseCommand): if len(app_labels) == 0: if primary_keys: raise CommandError("You can only use --pks option with one model") - app_list = OrderedDict( - (app_config, None) for app_config in apps.get_app_configs() + app_list = OrderedDict.fromkeys( + app_config for app_config in apps.get_app_configs() if app_config.models_module is not None and app_config not in excluded_apps ) else: diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py index b42f674eb0..7713b08e8c 100644 --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -10,7 +10,7 @@ class OrderedSet: """ def __init__(self, iterable=None): - self.dict = OrderedDict(((x, None) for x in iterable) if iterable else []) + self.dict = OrderedDict.fromkeys(iterable or ()) def add(self, item): self.dict[item] = None |
