From e4baf499edf2f234649c9646caedd06aa7aa57e6 Mon Sep 17 00:00:00 2001 From: Raphael Gaschignard Date: Tue, 18 Jun 2024 16:16:38 +0900 Subject: [PATCH] remove continue usage --- taggit/managers.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/taggit/managers.py b/taggit/managers.py index 023bf876..0ff8e976 100644 --- a/taggit/managers.py +++ b/taggit/managers.py @@ -255,10 +255,9 @@ def _to_tag_model_instances(self, tags, tag_kwargs): seen_tags = set() for t in tags: if isinstance(t, self.through.tag_model()): - if t in seen_tags: - continue - seen_tags.add(t) - result.append(t) + if t not in seen_tags: + seen_tags.add(t) + result.append(t) elif isinstance(t, str): # we are using a string, so either the tag exists (and we have the lookup) # or we need to create the value @@ -278,11 +277,9 @@ def _to_tag_model_instances(self, tags, tag_kwargs): # confirm if we've seen it or not (this is where case insensitivity comes # into play) - if existing_tag in seen_tags: - continue - - seen_tags.add(existing_tag) - result.append(existing_tag) + if existing_tag not in seen_tags: + seen_tags.add(existing_tag) + result.append(existing_tag) else: raise ValueError( "Cannot add {} ({}). Expected {} or str.".format(