Skip to content

Commit

Permalink
Merge pull request #3258 from openvinotoolkit/dk/fix-3252
Browse files Browse the repository at this point in the history
Fixed assignment in if statement
  • Loading branch information
ActiveChooN authored May 31, 2021
2 parents 2597546 + fe08472 commit 99bdfac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Project page requests took a long time and did many DB queries (<https://github.com/openvinotoolkit/cvat/pull/3223>)
- Fixed Python 3.6 support (<https://github.com/openvinotoolkit/cvat/pull/3258>)

### Security

Expand Down
6 changes: 4 additions & 2 deletions cvat/apps/engine/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ def update(self, instance, validated_data):
instance.label_set.all().delete()
else:
for old_label in instance.project.label_set.all():
if new_label_for_name := list(filter(lambda x: x.get('id', None) == old_label.id, labels)):
new_label_for_name = list(filter(lambda x: x.get('id', None) == old_label.id, labels))
if len(new_label_for_name):
old_label.name = new_label_for_name[0].get('name', old_label.name)
try:
new_label = project.label_set.filter(name=old_label.name).first()
Expand Down Expand Up @@ -458,7 +459,8 @@ def validate(self, attrs):
new_label_names = set()
old_labels = self.instance.project.label_set.all() if self.instance.project_id else self.instance.label_set.all()
for old_label in old_labels:
if len(new_labels := tuple(filter(lambda x: x.get('id') == old_label.id, attrs.get('label_set', [])))):
new_labels = tuple(filter(lambda x: x.get('id') == old_label.id, attrs.get('label_set', [])))
if len(new_labels):
new_label_names.add(new_labels[0].get('name', old_label.name))
else:
new_label_names.add(old_label.name)
Expand Down

0 comments on commit 99bdfac

Please sign in to comment.