Browse Source

ref(pyupgrade): set, dict literals wholesale on src/ (#23645)

josh 4 years ago
parent
commit
b7b5410897

+ 1 - 1
src/bitfield/admin.py

@@ -18,7 +18,7 @@ class BitFieldListFilter(FieldListFilter):
         super().__init__(field, request, params, model, model_admin, field_path)
 
     def queryset(self, request, queryset):
-        _filter = dict((p, bitor(F(p), v)) for p, v in six.iteritems(self.used_parameters))
+        _filter = {p: bitor(F(p), v) for p, v in six.iteritems(self.used_parameters)}
         try:
             return queryset.filter(**_filter)
         except ValidationError as e:

+ 1 - 1
src/sentry/api/bases/organization.py

@@ -241,7 +241,7 @@ class OrganizationEndpoint(Endpoint):
                     func = request.access.has_project_membership
                 projects = [p for p in qs if func(p)]
 
-        project_ids = set(p.id for p in projects)
+        project_ids = {p.id for p in projects}
 
         if requested_projects and project_ids != requested_projects:
             raise PermissionDenied

+ 1 - 1
src/sentry/api/bases/organization_events.py

@@ -198,7 +198,7 @@ class OrganizationEventsV2EndpointBase(OrganizationEventsEndpointBase):
         has_issues = "issue" in fields
         if has_issues:  # Look up the short ID and return that in the results
             if has_issues:
-                issue_ids = set(row.get("issue.id") for row in results)
+                issue_ids = {row.get("issue.id") for row in results}
                 issues = Group.issues_mapping(issue_ids, project_ids, organization)
             for result in results:
                 if has_issues and "issue.id" in result:

+ 1 - 1
src/sentry/api/endpoints/debug_files.py

@@ -39,7 +39,7 @@ from sentry.constants import DEBUG_FILES_ROLE_DEFAULT
 
 logger = logging.getLogger("sentry.api")
 ERR_FILE_EXISTS = "A file matching this debug identifier already exists"
-DIF_MIMETYPES = dict((v, k) for k, v in KNOWN_DIF_FORMATS.items())
+DIF_MIMETYPES = {v: k for k, v in KNOWN_DIF_FORMATS.items()}
 _release_suffix = re.compile(r"^(.*)\s+\(([^)]+)\)\s*$")
 
 

+ 1 - 1
src/sentry/api/endpoints/group_events.py

@@ -107,7 +107,7 @@ class GroupEventsEndpoint(GroupEndpoint, EnvironmentMixin):
             tags = {}
 
         if environments:
-            env_names = set(env.name for env in environments)
+            env_names = {env.name for env in environments}
             if "environment" in tags:
                 # If a single environment was passed as part of the query, then
                 # we'll just search for that individual environment in this

+ 3 - 3
src/sentry/api/endpoints/organization_group_index.py

@@ -262,9 +262,9 @@ class OrganizationGroupIndexEndpoint(OrganizationEventsEndpointBase):
                 # projects that the user is a member of. This gives us a better
                 # chance of returning the correct result, even if the wrong
                 # project is selected.
-                direct_hit_projects = set(project_ids) | set(
-                    [project.id for project in request.access.projects]
-                )
+                direct_hit_projects = set(project_ids) | {
+                    project.id for project in request.access.projects
+                }
                 groups = list(Group.objects.filter_by_event_id(direct_hit_projects, event_id))
                 if len(groups) == 1:
                     response = Response(

+ 1 - 1
src/sentry/api/endpoints/organization_member_unreleased_commits.py

@@ -58,7 +58,7 @@ class OrganizationMemberUnreleasedCommitsEndpoint(OrganizationMemberEndpoint):
         results = list(queryset)
 
         if results:
-            repos = list(Repository.objects.filter(id__in=set([r.repository_id for r in results])))
+            repos = list(Repository.objects.filter(id__in={r.repository_id for r in results}))
         else:
             repos = []
 

+ 1 - 1
src/sentry/api/endpoints/organization_plugins.py

@@ -10,7 +10,7 @@ from sentry.models import ProjectOption
 
 class OrganizationPluginsEndpoint(OrganizationEndpoint):
     def get(self, request, organization):
-        all_plugins = dict([(p.slug, p) for p in plugins.all()])
+        all_plugins = {p.slug: p for p in plugins.all()}
 
         if "plugins" in request.GET:
             if request.GET.get("plugins") == "_all":

+ 1 - 1
src/sentry/api/endpoints/organization_plugins_configs.py

@@ -74,7 +74,7 @@ class OrganizationPluginsConfigsEndpoint(OrganizationEndpoint):
                 info_by_plugin_project[slug][project_id]["configured"] = True
 
         # get the IDs of all projects for found project options and grab them from the DB
-        project_id_set = set([project_option.project_id for project_option in project_options])
+        project_id_set = {project_option.project_id for project_option in project_options}
         projects = Project.objects.filter(id__in=project_id_set, status=ObjectStatus.VISIBLE)
 
         # create a key/value map of our projects

+ 1 - 1
src/sentry/api/endpoints/organization_release_meta.py

@@ -59,7 +59,7 @@ class OrganizationReleaseMetaEndpoint(OrganizationReleasesBaseEndpoint):
         )
 
         platforms = ProjectPlatform.objects.filter(
-            project_id__in=set(x["project__id"] for x in project_releases)
+            project_id__in={x["project__id"] for x in project_releases}
         ).values_list("project_id", "platform")
         platforms_by_project = defaultdict(list)
         for project_id, platform in platforms:

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