From 01299acb16e0574f680bc017de9ef01ce8da26b4 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Fri, 19 Jul 2024 11:48:48 +0100 Subject: [PATCH] Update code for flake8-comprehensions C420 --- src/django_upgrade/fixers/compatibility_imports.py | 10 +++++----- src/django_upgrade/fixers/django_urls.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/django_upgrade/fixers/compatibility_imports.py b/src/django_upgrade/fixers/compatibility_imports.py index a2e9eb17..32ea2e92 100644 --- a/src/django_upgrade/fixers/compatibility_imports.py +++ b/src/django_upgrade/fixers/compatibility_imports.py @@ -59,7 +59,7 @@ "django.contrib.staticfiles.templatetags.staticfiles": { "static": "django.templatetags.static", }, - "django.core.urlresolvers": { + "django.core.urlresolvers": dict.fromkeys( # Objects moved from django.core.resolvers to django.urls in # Django 1.10: # https://github.com/django/django/blob/stable/1.10.x/django/urls/__init__.py @@ -67,8 +67,7 @@ # 2.0: RegexURLPattern, LocaleRegexURLResolver, RegexURLResolver # and LocaleRegexProvider. See: # https://github.com/django/django/pull/7482#discussion_r121311884 - name: "django.urls" - for name in ( + ( "NoReverseMatch", "Resolver404", "ResolverMatch", @@ -87,8 +86,9 @@ "set_script_prefix", "set_urlconf", "translate_url", - ) - }, + ), + "django.urls", + ), }, (1, 11): { "django.db.models.fields": { diff --git a/src/django_upgrade/fixers/django_urls.py b/src/django_upgrade/fixers/django_urls.py index f7b97f11..acb4b54f 100644 --- a/src/django_upgrade/fixers/django_urls.py +++ b/src/django_upgrade/fixers/django_urls.py @@ -90,7 +90,7 @@ def update_django_conf_import( tokens, i, node=node, - name_map={name: "" for name in removals}, + name_map=dict.fromkeys(removals, ""), ) if not re_path_imported: joined_names = ", ".join(sorted(added_names))