Skip to content

Commit edbb264

Browse files
committed
pyupgrade: converts str.format() into f-strings.
1 parent 97d6f6d commit edbb264

File tree

8 files changed

+12
-12
lines changed

8 files changed

+12
-12
lines changed

fluent_pages/extensions/pagetypepool.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def _get_plugin_by_content_type(self, contenttype):
136136
else:
137137
ct_name = f"{ct.app_label}.{ct.model}"
138138
raise PageTypeNotFound(
139-
"No plugin found for content type #{} ({}).".format(contenttype, ct_name)
139+
f"No plugin found for content type #{contenttype} ({ct_name})."
140140
)
141141

142142
return self.plugins[name]

fluent_pages/management/commands/make_language_redirects.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def handle(self, *args, **options):
6565
raise CommandError(f"No URLs found for site {site} in {from_name}")
6666

6767
self.stdout.write(
68-
"# Redirecting all translated {} URLs to the {} site\n".format(from_name, to_name)
68+
f"# Redirecting all translated {from_name} URLs to the {to_name} site\n"
6969
)
7070
self.stdout.write("# Generated using {}".format(" ".join(sys.argv)))
7171

@@ -92,7 +92,7 @@ def handle(self, *args, **options):
9292
)
9393
else:
9494
self.stdout.write(
95-
"location {0} {{ return 301 {1}{2}; }}\n".format(from_rule, host, to_url)
95+
f"location {from_rule} {{ return 301 {host}{to_url}; }}\n"
9696
)
9797

9898
# Final redirect for all identical URLs

fluent_pages/models/db.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ def _update_cached_url(self, translation):
572572
if self.is_file:
573573
translation._cached_url = f"{parent_url}{translation.slug}"
574574
else:
575-
translation._cached_url = "{}{}/".format(parent_url, translation.slug)
575+
translation._cached_url = f"{parent_url}{translation.slug}/"
576576

577577
def _update_decendant_urls(self, translation):
578578
"""
@@ -687,7 +687,7 @@ def _expire_url_caches(self):
687687
"""
688688
cachekeys = [
689689
# created by urlresolvers._get_pages_of_type()
690-
"fluent_pages.instance_of.{}.{}".format(self.__class__.__name__, self.parent_site_id)
690+
f"fluent_pages.instance_of.{self.__class__.__name__}.{self.parent_site_id}"
691691
]
692692
for cachekey in cachekeys:
693693
cache.delete(cachekey)

fluent_pages/models/managers.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def get_for_path(self, path, language_code=None):
6666
return obj
6767
except self.model.DoesNotExist:
6868
raise self.model.DoesNotExist(
69-
"No published {} found for the path '{}'".format(self.model.__name__, path)
69+
f"No published {self.model.__name__} found for the path '{path}'"
7070
)
7171

7272
def best_match_for_path(self, path, language_code=None):
@@ -100,7 +100,7 @@ def best_match_for_path(self, path, language_code=None):
100100
return obj
101101
except IndexError:
102102
raise self.model.DoesNotExist(
103-
"No published {} found for the path '{}'".format(self.model.__name__, path)
103+
f"No published {self.model.__name__} found for the path '{path}'"
104104
)
105105

106106
def _split_path_levels(self, path):
@@ -138,7 +138,7 @@ def get_for_key(self, key):
138138
)
139139
else:
140140
raise self.model.DoesNotExist(
141-
"{} with key='{}' does not exist.".format(self.model.__name__, key)
141+
f"{self.model.__name__} with key='{key}' does not exist."
142142
)
143143

144144
def parent_site(self, site):

fluent_pages/models/navigation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def parent(self):
155155
def parent(self, new_parent):
156156
# Happens when django-mptt finds an object with a different level in the recursetree() / cache_tree_children() code.
157157
raise AttributeError(
158-
"can't set attribute 'parent' of '{}' object.".format(self.__class__.__name__)
158+
f"can't set attribute 'parent' of '{self.__class__.__name__}' object."
159159
)
160160

161161
@property

fluent_pages/tests/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def assert404(self, url, msg_prefix=""):
9292
response.status_code,
9393
404,
9494
str(msg_prefix)
95-
+ "Page at {} should return 404, got {}.".format(url, response.status_code),
95+
+ f"Page at {url} should return 404, got {response.status_code}.",
9696
)
9797

9898

fluent_pages/urlresolvers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def _get_pages_of_type(model, language_code=None):
148148
if language_code is None:
149149
language_code = get_language()
150150

151-
cachekey = "fluent_pages.instance_of.{}.{}".format(model.__name__, settings.SITE_ID)
151+
cachekey = f"fluent_pages.instance_of.{model.__name__}.{settings.SITE_ID}"
152152
pages = cache.get(cachekey)
153153
if not pages:
154154
pages = (

fluent_pages/views/dispatcher.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def _call_url_view(self, plugin, sub_path, match):
286286
)
287287
if response is None:
288288
raise RuntimeError(
289-
"The view '{}' didn't return an HttpResponse object.".format(match.url_name)
289+
f"The view '{match.url_name}' didn't return an HttpResponse object."
290290
)
291291

292292
return response

0 commit comments

Comments
 (0)