Skip to content

Commit 4535603

Browse files
committed
Added annotations to pass lint static code check
1 parent a18839f commit 4535603

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

entity/api_v2/views.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from distutils.util import strtobool
2+
from typing import Dict, List
23

34
from django.db.models import Count, F
45
from django.http import Http404
@@ -284,14 +285,16 @@ def get_queryset(self):
284285
def get(self, request):
285286
queryset = self.get_queryset()
286287

287-
entity_ids = list(filter(None, self.request.query_params.get("entity_ids", "").split(",")))
288+
entity_ids: List[int] = list(
289+
filter(None, self.request.query_params.get("entity_ids", "").split(","))
290+
)
288291
names_query = queryset.values("name")
289292
if len(entity_ids) > 0:
290293
names_query = names_query.annotate(count=Count("name")).filter(count=len(entity_ids))
291294

292295
# Compile each attribute of referrals by attribute name
293296
serializer: Serializer = self.get_serializer(queryset)
294-
results = {}
297+
results: Dict[str, Dict] = {}
295298
for attrname in names_query.values_list("name", flat=True):
296299
for attrinfo in [x for x in serializer.data if x["name"] == attrname]:
297300
if attrname in results:

entry/api_v2/views.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,11 @@ def _get_joined_resp(prev_results, join_attr):
375375
ref_info["value"].get("id") is None
376376
):
377377
# join EMPTY value
378-
resp_result["attrs"] |= blank_joining_info
378+
resp_result["attrs"] |= blank_joining_info # type: ignore
379379

380380
# joining search result to original one
381-
ref_id = ref_info["value"].get("id")
382-
if ref_id in joined_resp_info:
381+
ref_id = ref_info["value"].get("id") if "value" in ref_info is not None else None # type: ignore
382+
if ref_id and ref_id in joined_resp_info: # type: ignore
383383
# join valid value
384384
resp_result["attrs"] |= joined_resp_info[ref_id]
385385

@@ -388,7 +388,7 @@ def _get_joined_resp(prev_results, join_attr):
388388

389389
else:
390390
# join EMPTY value
391-
resp_result["attrs"] |= blank_joining_info
391+
resp_result["attrs"] |= blank_joining_info # type: ignore
392392

393393
if will_filter_by_joined_attr:
394394
resp["ret_values"] = new_ret_values

0 commit comments

Comments
 (0)