Skip to content

Commit

Permalink
Update syntax to Python +3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
hramezani committed Dec 21, 2021
1 parent 2eff7ed commit 6ffa01c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions taggit/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, alias, col, content_types):
def as_sql(self, compiler, connection):
qn = compiler.quote_name_unless_alias
if len(self.content_types) == 1:
extra_where = "{}.{} = %s".format(qn(self.alias), qn(self.col))
extra_where = f"{qn(self.alias)}.{qn(self.col)} = %s"
else:
extra_where = "{}.{} IN ({})".format(
qn(self.alias), qn(self.col), ",".join(["%s"] * len(self.content_types))
Expand Down Expand Up @@ -228,7 +228,7 @@ def _to_tag_model_instances(self, tags, tag_kwargs):
# do a query. Malcolm is very smart.
existing = manager.filter(name__in=str_tags, **tag_kwargs)

tags_to_create = str_tags - set(t.name for t in existing)
tags_to_create = str_tags - {t.name for t in existing}

tag_objs.update(existing)

Expand Down
6 changes: 3 additions & 3 deletions taggit/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(self, **kwargs):
kwargs["style"] = {"base_template": "textarea.html"}
kwargs["style"].update(style)

super(TagListSerializerField, self).__init__(**kwargs)
super().__init__(**kwargs)

self.pretty_print = pretty_print

Expand Down Expand Up @@ -95,14 +95,14 @@ class TaggitSerializer(serializers.Serializer):
def create(self, validated_data):
to_be_tagged, validated_data = self._pop_tags(validated_data)

tag_object = super(TaggitSerializer, self).create(validated_data)
tag_object = super().create(validated_data)

return self._save_tags(tag_object, to_be_tagged)

def update(self, instance, validated_data):
to_be_tagged, validated_data = self._pop_tags(validated_data)

tag_object = super(TaggitSerializer, self).update(instance, validated_data)
tag_object = super().update(instance, validated_data)

return self._save_tags(tag_object, to_be_tagged)

Expand Down
8 changes: 4 additions & 4 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ def test_lookup_by_tag(self):
model_name = self.pet_model.__name__
self.assertQuerysetEqual(
pks,
["<{}: kitty>".format(model_name), "<{}: cat>".format(model_name)],
[f"<{model_name}: kitty>", f"<{model_name}: cat>"],
ordered=False,
)

Expand All @@ -605,7 +605,7 @@ def test_exclude(self):
model_name = self.food_model.__name__
self.assertQuerysetEqual(
pks,
["<{}: pear>".format(model_name), "<{}: guava>".format(model_name)],
[f"<{model_name}: pear>", f"<{model_name}: guava>"],
ordered=False,
)

Expand Down Expand Up @@ -1234,7 +1234,7 @@ def setUp(self):
self.strawberry.tags.add("red")

def test_url_request_returns_view(self):
request = self.factory.get("/food/tags/{}/".format(self.slug))
request = self.factory.get(f"/food/tags/{self.slug}/")
queryset = self.model.objects.all()
response = tagged_object_list(request, self.slug, queryset)
self.assertEqual(response.status_code, 200)
Expand All @@ -1245,7 +1245,7 @@ def test_url_request_returns_view(self):
)

def test_list_view_returns_single(self):
response = self.client.get("/food/tags/{}/".format(self.slug))
response = self.client.get(f"/food/tags/{self.slug}/")
self.assertEqual(response.status_code, 200)
self.assertIn(self.apple, response.context_data["object_list"])
self.assertNotIn(self.strawberry, response.context_data["object_list"])
Expand Down

0 comments on commit 6ffa01c

Please sign in to comment.