Skip to content

Commit b8faed8

Browse files
authored
Adjusted some still old formatted strings to f-strings (#1131)
1 parent acffc18 commit b8faed8

File tree

6 files changed

+7
-6
lines changed

6 files changed

+7
-6
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ any parts of the framework not mentioned in the documentation should generally b
1717
### Changed
1818

1919
* Added support to overwrite serializer methods in customized schema class
20+
* Adjusted some still old formatted strings to f-strings.
2021

2122
### Fixed
2223

docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
# General information about the project.
6262
project = "Django REST framework JSON:API"
6363
year = datetime.date.today().year
64-
copyright = "{}, Django REST framework JSON:API contributors".format(year)
64+
copyright = f"{year}, Django REST framework JSON:API contributors"
6565
author = "Django REST framework JSON:API contributors"
6666

6767
# The version info for the project you're documenting, acts as replacement for

rest_framework_json_api/django_filters/backends.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,5 @@ def get_schema_operation_parameters(self, view):
142142
for res in result:
143143
if "name" in res:
144144
name = format_field_name(res["name"].replace("__", "."))
145-
res["name"] = "filter[{}]".format(name)
145+
res["name"] = f"filter[{name}]"
146146
return result

rest_framework_json_api/renderers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def extract_relationships(cls, fields, resource, resource_instance):
166166
(relations.PrimaryKeyRelatedField, relations.HyperlinkedRelatedField),
167167
):
168168
resolved, relation = utils.get_relation_instance(
169-
resource_instance, "%s_id" % source, field.parent
169+
resource_instance, f"{source}_id", field.parent
170170
)
171171
if not resolved:
172172
continue
@@ -341,7 +341,7 @@ def extract_included(
341341
serializer_data = field.data
342342

343343
new_included_resources = [
344-
key.replace("%s." % field_name, "", 1)
344+
key.replace(f"{field_name}.", "", 1)
345345
for key in included_resources
346346
if field_name == key.split(".")[0]
347347
]

rest_framework_json_api/settings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __init__(self, user_settings=settings, defaults=DEFAULTS):
3030

3131
def __getattr__(self, attr):
3232
if attr not in self.defaults:
33-
raise AttributeError("Invalid JSON:API setting: '%s'" % attr)
33+
raise AttributeError(f"Invalid JSON:API setting: '{attr}'")
3434

3535
value = getattr(
3636
self.user_settings, JSON_API_SETTINGS_PREFIX + attr, self.defaults[attr]

rest_framework_json_api/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def get_related_resource_type(relation):
269269
if hasattr(relation, "child_relation"):
270270
return get_related_resource_type(relation.child_relation)
271271
raise APIException(
272-
_("Could not resolve resource type for relation %s" % relation)
272+
_(f"Could not resolve resource type for relation {relation}")
273273
)
274274

275275
return get_resource_type_from_model(relation_model)

0 commit comments

Comments
 (0)