Skip to content

Commit

Permalink
chore: type annotate and simplify template tags
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed Oct 21, 2024
1 parent bd02403 commit a959e63
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions weblate_web/templatetags/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@
register = Library()


def filesizeformat(num_bytes):
def filesizeformat(num_bytes: int):
"""
Format the value like a 'human-readable' file size.
For example 13 KB, 4.1 MB, 102 bytes, etc).
"""
num_bytes = float(num_bytes)

if num_bytes < 1024:
return ngettext("%(size)d byte", "%(size)d bytes", num_bytes) % {
"size": num_bytes
Expand All @@ -45,7 +43,7 @@ def filesizeformat(num_bytes):


@register.inclusion_tag("snippets/download-link.html")
def downloadlink(info):
def downloadlink(info: dict[str, str]):
name = info["filename"]

if name.endswith(".tar.bz2"):
Expand Down

0 comments on commit a959e63

Please sign in to comment.