diff --git a/downloads/management/commands/add_file.py b/downloads/management/commands/add_file.py
index 19d7722b..e59be669 100644
--- a/downloads/management/commands/add_file.py
+++ b/downloads/management/commands/add_file.py
@@ -29,7 +29,7 @@ def handle(self, *args, **options):
dlpath = dlpath[:-1]
for f in options["file"]:
- self.stdout.write("Adding %s..." % f)
+ self.stdout.write(f"Adding {f}...")
filename = os.path.basename(f)
with open(f, "rb") as handle:
diff --git a/downloads/models.py b/downloads/models.py
index e42f249a..74d5a61a 100644
--- a/downloads/models.py
+++ b/downloads/models.py
@@ -113,10 +113,7 @@ def save(self, *args, **kwargs):
programurl=f"https://{current_site}{PROGRAM_URLS[self.program]}",
versionurl=f"https://{current_site}{self.get_absolute_url()}",
)
- body = (
- "Full list of changes:\n\n%s\n\nYou can download it from .\n\nSupport this program by donations ."
- % self.changelog
- )
+ body = f"Full list of changes:\n\n{self.changelog}\n\nYou can download it from .\n\nSupport this program by donations ."
title = f"{get_program(self.program)} {self.version}"
slug = "{}-{}".format(
self.program,
diff --git a/downloads/views.py b/downloads/views.py
index 463f34ac..bd406c40 100644
--- a/downloads/views.py
+++ b/downloads/views.py
@@ -12,7 +12,8 @@
def detail(request, program):
if program not in (x[0] for x in PROGRAM_CHOICES):
- raise Http404("No such program %s." % program)
+ msg = f"No such program {program}."
+ raise Http404(msg)
downloads = get_current_downloads(program)
@@ -23,7 +24,8 @@ def detail(request, program):
testing_release, testing_downloads = (None, None)
if stable_downloads.count() == 0:
- raise Http404("No such download option %s." % program)
+ msg = f"No such download option {program}."
+ raise Http404(msg)
return render(
request,
@@ -64,13 +66,14 @@ def download(request):
def doap(request, program):
if program not in (x[0] for x in PROGRAM_CHOICES):
- raise Http404("No such program %s." % program)
+ msg = f"No such program {program}."
+ raise Http404(msg)
downloads = get_current_downloads(program)
return render(
request,
- "downloads/doap/%s.xml" % program,
+ f"downloads/doap/{program}.xml",
{
"downloads": downloads[0][1],
"release": downloads[0][0],
@@ -81,7 +84,8 @@ def doap(request, program):
def pad(request, program):
if program not in (x[0] for x in PROGRAM_CHOICES):
- raise Http404("No such program %s." % program)
+ msg = f"No such program {program}."
+ raise Http404(msg)
downloads = get_current_downloads(program)
@@ -96,7 +100,7 @@ def pad(request, program):
return render(
request,
- "downloads/pad/%s.xml" % program,
+ f"downloads/pad/{program}.xml",
{
"download": download,
"release": release,
diff --git a/news/views.py b/news/views.py
index 88e20373..2f83eb42 100644
--- a/news/views.py
+++ b/news/views.py
@@ -30,7 +30,7 @@ def category(request, slug):
.order_by("-pub_date")
.prefetch_related("author")
)
- return render_news(request, objects, "news/%s_index.html" % slug)
+ return render_news(request, objects, f"news/{slug}_index.html")
def render_news(request, objects, template):
diff --git a/phonedb/forms.py b/phonedb/forms.py
index a801e7bd..69b4ef2e 100644
--- a/phonedb/forms.py
+++ b/phonedb/forms.py
@@ -36,7 +36,7 @@ def __init__(self, *args, **kwargs):
_('%(description)s [Link]')
% {
"description": f.get_description(),
- "url": "/phones/search/%s/" % f.name,
+ "url": f"/phones/search/{f.name}/",
},
),
)
diff --git a/phonedb/models.py b/phonedb/models.py
index 4d03d323..33114a95 100644
--- a/phonedb/models.py
+++ b/phonedb/models.py
@@ -173,7 +173,7 @@ def get_related_sites(self):
name = self.__str__().replace(" ", "_").replace("-", "_")
result.append(
{
- "url": "https://wikipedia.org/wiki/%s" % name,
+ "url": f"https://wikipedia.org/wiki/{name}",
"name": "Wikipedia",
},
)
@@ -195,8 +195,7 @@ def get_related_sites(self):
name = name[:-1] + "_fold"
result.append(
{
- "url": "http://www.developer.nokia.com/Devices/Device_specifications/%s/"
- % name,
+ "url": f"http://www.developer.nokia.com/Devices/Device_specifications/{name}/",
"name": "Nokia Developer",
},
)
diff --git a/phonedb/views.py b/phonedb/views.py
index 7ad4ac09..cf5b6b28 100644
--- a/phonedb/views.py
+++ b/phonedb/views.py
@@ -28,7 +28,7 @@
def get_chart_url(force=False):
- cache_key = "phonedb-chart-url-%s" % settings.LANGUAGE_CODE
+ cache_key = f"phonedb-chart-url-{settings.LANGUAGE_CODE}"
url = cache.get(cache_key)
if url is not None and not force:
return url
@@ -195,12 +195,12 @@ def search(request, featurename=None):
if len(features) > 0:
phones = phones.filter(connection__isnull=False)
for feature in features:
- urlparams.append("feature=%s" % feature)
+ urlparams.append(f"feature={feature}")
phones = phones.filter(features__name=feature)
# Filter for query string
if query:
- urlparams.append("q=%s" % query)
+ urlparams.append(f"q={query}")
query = query.strip()
for part in query.split():
phones = phones.filter(
@@ -501,7 +501,7 @@ def create_wammu(request): # noqa: C901
features = []
for feature in Feature.objects.all():
- key = "fts[%s]" % feature.name
+ key = f"fts[{feature.name}]"
if key in request.POST and request.POST[key] == "1":
features.append(feature)
diff --git a/pyproject.toml b/pyproject.toml
index 666e1bb8..f070446a 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -2,6 +2,9 @@
profile = "black"
[tool.ruff]
+output-format = "github"
+
+[tool.ruff.lint]
extend-safe-fixes = [
"D",
"TCH",
@@ -44,10 +47,11 @@ ignore = [
"EM101",
"PT",
"PTH",
- "ANN"
+ "ANN",
+ "COM812",
+ "ISC001"
]
-output-format = "github"
select = ["ALL"]
-[tool.ruff.mccabe]
+[tool.ruff.lint.mccabe]
max-complexity = 16
diff --git a/screenshots/thumbs.py b/screenshots/thumbs.py
index 39aeaf10..0d154980 100644
--- a/screenshots/thumbs.py
+++ b/screenshots/thumbs.py
@@ -96,8 +96,9 @@ def save(self, name, content, save=True):
thumb_name_ = self.storage.save(thumb_name, thumb_content)
- if not thumb_name == thumb_name_:
- raise ValueError("There is already a file named %s" % thumb_name)
+ if thumb_name != thumb_name_:
+ msg = f"There is already a file named {thumb_name}"
+ raise ValueError(msg)
def delete(self, save=True):
name = self.name
diff --git a/screenshots/views.py b/screenshots/views.py
index af7f6b26..25eae878 100644
--- a/screenshots/views.py
+++ b/screenshots/views.py
@@ -15,7 +15,7 @@ def index(request):
def category(request, slug):
category = get_object_or_404(Category, slug=slug)
objects = Screenshot.objects.filter(categories=category).order_by("title")
- return render_screenshots(request, objects, "screenshots/%s_index.html" % slug)
+ return render_screenshots(request, objects, f"screenshots/{slug}_index.html")
def render_screenshots(request, objects, template):
diff --git a/settings.py b/settings.py
index 5ef2959b..aba25fbc 100644
--- a/settings.py
+++ b/settings.py
@@ -49,7 +49,7 @@
("sk", "Slovenčina"),
)
-LOCALE_PATHS = ("%s/locale" % WEB_ROOT,)
+LOCALE_PATHS = (f"{WEB_ROOT}/locale",)
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
@@ -59,9 +59,9 @@
# calendars according to the current locale
# Absolute filesystem path to the directory that will hold user-uploaded files.
-MEDIA_ROOT = "%s/media/" % WEB_ROOT
+MEDIA_ROOT = f"{WEB_ROOT}/media/"
-HTML_ROOT = "%s/html/" % WEB_ROOT
+HTML_ROOT = f"{WEB_ROOT}/html/"
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
diff --git a/tools/templatetags/encoding.py b/tools/templatetags/encoding.py
index 438eb573..77b9c2ed 100644
--- a/tools/templatetags/encoding.py
+++ b/tools/templatetags/encoding.py
@@ -22,9 +22,11 @@ def base64(value):
@register.filter
def xpm2png(value):
xpm = """/* XPM */
-static char * ala_xpm[] = {
-"%s"};""" % '",\n"'.join(
- value,
+static char * ala_xpm[] = {{
+"{}"}};""".format(
+ '",\n"'.join(
+ value,
+ )
)
xpm = xpm.replace("None", "#ffffff").replace("Black", "#000000")
io = StringIO(xpm)
@@ -41,6 +43,6 @@ def xpm2png(value):
def wrap(value):
ret = ""
while len(value) > 0:
- ret += "%s\n" % value[:32]
+ ret += f"{value[:32]}\n"
value = value[32:]
return ret
diff --git a/urls.py b/urls.py
index dbe23f7b..1a370a74 100644
--- a/urls.py
+++ b/urls.py
@@ -48,39 +48,39 @@ class PagesSitemap(Sitemap):
def items(self):
return [
- ("/", "%s/index.html" % settings.HTML_ROOT, 1),
- ("/gammu/", "%s/gammu.html" % settings.HTML_ROOT, 1),
- ("/libgammu/", "%s/libgammu.html" % settings.HTML_ROOT, 1),
- ("/wammu/", "%s/wammu.html" % settings.HTML_ROOT, 1),
- ("/smsd/", "%s/smsd.html" % settings.HTML_ROOT, 1),
- ("/python-gammu/", "%s/python-gammu.html" % settings.HTML_ROOT, 1),
- ("/authors/", "%s/authors.html" % settings.HTML_ROOT, 0.9),
- ("/license/", "%s/libgammu.html" % settings.HTML_ROOT, 0.9),
- ("/donate/", "%s/donate.html" % settings.HTML_ROOT, 0.3),
- ("/s60/", "%s/s60.html" % settings.HTML_ROOT, 0.3),
- ("/support/", "%s/support/index.html" % settings.HTML_ROOT, 0.9),
- ("/support/bugs/", "%s/support/bugs.html" % settings.HTML_ROOT, 0.9),
- ("/support/lists/", "%s/support/lists.html" % settings.HTML_ROOT, 0.9),
- ("/support/online/", "%s/support/online.html" % settings.HTML_ROOT, 0.9),
- ("/support/buy/", "%s/support/buy.html" % settings.HTML_ROOT, 0.9),
- ("/contribute/", "%s/contribute/index.html" % settings.HTML_ROOT, 0.9),
- ("/contribute/code/", "%s/contribute/code.html" % settings.HTML_ROOT, 0.9),
+ ("/", f"{settings.HTML_ROOT}/index.html", 1),
+ ("/gammu/", f"{settings.HTML_ROOT}/gammu.html", 1),
+ ("/libgammu/", f"{settings.HTML_ROOT}/libgammu.html", 1),
+ ("/wammu/", f"{settings.HTML_ROOT}/wammu.html", 1),
+ ("/smsd/", f"{settings.HTML_ROOT}/smsd.html", 1),
+ ("/python-gammu/", f"{settings.HTML_ROOT}/python-gammu.html", 1),
+ ("/authors/", f"{settings.HTML_ROOT}/authors.html", 0.9),
+ ("/license/", f"{settings.HTML_ROOT}/libgammu.html", 0.9),
+ ("/donate/", f"{settings.HTML_ROOT}/donate.html", 0.3),
+ ("/s60/", f"{settings.HTML_ROOT}/s60.html", 0.3),
+ ("/support/", f"{settings.HTML_ROOT}/support/index.html", 0.9),
+ ("/support/bugs/", f"{settings.HTML_ROOT}/support/bugs.html", 0.9),
+ ("/support/lists/", f"{settings.HTML_ROOT}/support/lists.html", 0.9),
+ ("/support/online/", f"{settings.HTML_ROOT}/support/online.html", 0.9),
+ ("/support/buy/", f"{settings.HTML_ROOT}/support/buy.html", 0.9),
+ ("/contribute/", f"{settings.HTML_ROOT}/contribute/index.html", 0.9),
+ ("/contribute/code/", f"{settings.HTML_ROOT}/contribute/code.html", 0.9),
(
"/contribute/translate/",
- "%s/contribute/translate.html" % settings.HTML_ROOT,
+ f"{settings.HTML_ROOT}/contribute/translate.html",
0.9,
),
(
"/contribute/publicity/",
- "%s/contribute/publicity.html" % settings.HTML_ROOT,
+ f"{settings.HTML_ROOT}/contribute/publicity.html",
0.9,
),
(
"/contribute/wanted/",
- "%s/contribute/wanted.html" % settings.HTML_ROOT,
+ f"{settings.HTML_ROOT}/contribute/wanted.html",
0.9,
),
- ("/docs/", "%s/docs/index.html" % settings.HTML_ROOT, 0.9),
+ ("/docs/", f"{settings.HTML_ROOT}/docs/index.html", 0.9),
("/screenshots/", None, 0.8),
("/downloads/gammu/", None, 0.7),
("/downloads/python-gammu/", None, 0.7),
diff --git a/wammu/context_processors.py b/wammu/context_processors.py
index 7ffcd1bf..b18187e2 100644
--- a/wammu/context_processors.py
+++ b/wammu/context_processors.py
@@ -17,43 +17,43 @@ def translations(request):
if lang != "cs":
langs.append(
- {"url": "https://cs.wammu.eu%s" % path, "name": "Česky", "code": "cs"},
+ {"url": f"https://cs.wammu.eu{path}", "name": "Česky", "code": "cs"},
)
if lang != "en":
langs.append(
- {"url": "https://wammu.eu%s" % path, "name": "English", "code": "en"},
+ {"url": f"https://wammu.eu{path}", "name": "English", "code": "en"},
)
if lang != "es":
langs.append(
- {"url": "https://es.wammu.eu%s" % path, "name": "Español", "code": "es"},
+ {"url": f"https://es.wammu.eu{path}", "name": "Español", "code": "es"},
)
if lang != "de":
langs.append(
- {"url": "https://de.wammu.eu%s" % path, "name": "Deutsch", "code": "de"},
+ {"url": f"https://de.wammu.eu{path}", "name": "Deutsch", "code": "de"},
)
if lang != "ru":
langs.append(
- {"url": "https://ru.wammu.eu%s" % path, "name": "Русский", "code": "ru"},
+ {"url": f"https://ru.wammu.eu{path}", "name": "Русский", "code": "ru"},
)
if lang != "sk":
langs.append(
- {"url": "https://sk.wammu.eu%s" % path, "name": "Slovenčina", "code": "sk"},
+ {"url": f"https://sk.wammu.eu{path}", "name": "Slovenčina", "code": "sk"},
)
if lang != "fr":
langs.append(
- {"url": "https://fr.wammu.eu%s" % path, "name": "Français", "code": "fr"},
+ {"url": f"https://fr.wammu.eu{path}", "name": "Français", "code": "fr"},
)
if lang != "pt-br":
langs.append(
{
- "url": "https://pt-br.wammu.eu%s" % path,
+ "url": f"https://pt-br.wammu.eu{path}",
"name": "Português brasileiro",
"code": "pt-BR",
},