Skip to content

Commit

Permalink
Removes and renames unused or missing variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugh Enxing committed Aug 10, 2023
1 parent 2122886 commit 3fa3932
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions api/main/rest/attribute_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def _modify_attribute_type(cls, params: Dict, mod_type: str) -> Dict:

ts = TatorSearch()
old_name = params["current_name"]
old_dtype = None
old_attribute_type = None
attribute_type_update = params["attribute_type_update"]

Expand All @@ -128,11 +127,9 @@ def _modify_attribute_type(cls, params: Dict, mod_type: str) -> Dict:
# Get the old and new dtypes
with transaction.atomic():
entity_type, obj_qs = cls._get_objects(params)
has_related_objects = cls._has_related_objects(entity_type, old_name)

for attribute_type in entity_type.attribute_types:
if attribute_type["name"] == old_name:
old_dtype = attribute_type["dtype"]
old_attribute_type = dict(attribute_type)
break
else:
Expand Down Expand Up @@ -199,10 +196,8 @@ def _modify_attribute_type(cls, params: Dict, mod_type: str) -> Dict:
if dtype_mutated:
if obj_qs.exists():
# Get the new attribute type to convert the existing value
new_attribute = None
for attribute_type in entity_type.attribute_types:
if attribute_type["name"] == new_name:
new_attribute = attribute_type
break

if mod_type == "update":
Expand Down Expand Up @@ -255,7 +250,7 @@ def _post(self, params: Dict) -> Dict:
if entity_type.attribute_types:
existing_names = [a["name"] for a in entity_type.attribute_types]
if attribute_type_update["name"] in existing_names:
raise ValueError(f"{a['name']} is already an attribute.")
raise ValueError(f"{attribute_type_update['name']} is already an attribute.")
entity_type.attribute_types.append(attribute_type_update)
else:
entity_type.attribute_types = []
Expand Down

0 comments on commit 3fa3932

Please sign in to comment.