prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  ValueError: Unknown format code 'X' for object of type 'str'
  Sentry Issue: [SITE-25](https://sentry.io/organizations/python-discord/issues/3211854811/?referrer=github_integration)
  
  ```
  ValueError: Unknown format code 'X' for object of type 'str'
  (16 additional frame(s) were not displayed)
  ...
    File "django/template/defaulttags.py", line 211, in render
      nodelist.append(node.render_annotated(context))
    File "django/template/base.py", line 905, in render_annotated
      return self.render(context)
    File "django/template/base.py", line 988, in render
      output = self.filter_expression.resolve(context)
    File "django/template/base.py", line 698, in resolve
      new_obj = func(obj, *arg_vals)
    File "pydis_site/apps/staff/templatetags/deletedmessage_filters.py", line 15, in hex_colour
      colour = f"#{color:0>6X}"
  ```
  
  </issue>
  <code>
  [start of pydis_site/apps/staff/templatetags/deletedmessage_filters.py]
  1 from datetime import datetime
  2 
  3 from django import template
  4 
  5 register = template.Library()
  6 
  7 
  8 @register.filter
  9 def hex_colour(color: int) -> str:
  10     """
  11     Converts an integer representation of a colour to the RGB hex value.
  12 
  13     As we are using a Discord dark theme analogue, black colours are returned as white instead.
  14     """
  15     colour = f"#{color:0>6X}"
  16     return colour if colour != "#000000" else "#FFFFFF"
  17 
  18 
  19 @register.filter
  20 def footer_datetime(timestamp: str) -> datetime:
  21     """Takes an embed timestamp and returns a timezone-aware datetime object."""
  22     return datetime.fromisoformat(timestamp)
  23 
  24 
  25 @register.filter
  26 def visible_newlines(text: str) -> str:
  27     """Takes an embed timestamp and returns a timezone-aware datetime object."""
  28     return text.replace("\n", " <span class='has-text-grey'>↵</span><br>")
  29
  [end of pydis_site/apps/staff/templatetags/deletedmessage_filters.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/pydis_site/apps/staff/templatetags/deletedmessage_filters.py b/pydis_site/apps/staff/templatetags/deletedmessage_filters.py
  --- a/pydis_site/apps/staff/templatetags/deletedmessage_filters.py
  +++ b/pydis_site/apps/staff/templatetags/deletedmessage_filters.py
  @@ -1,4 +1,5 @@
   from datetime import datetime
  +from typing import Union
   
   from django import template
   
  @@ -6,13 +7,16 @@
   
   
   @register.filter
  -def hex_colour(color: int) -> str:
  +def hex_colour(colour: Union[str, int]) -> str:
       """
  -    Converts an integer representation of a colour to the RGB hex value.
  +    Converts the given representation of a colour to its RGB hex string.
   
       As we are using a Discord dark theme analogue, black colours are returned as white instead.
       """
  -    colour = f"#{color:0>6X}"
  +    if isinstance(colour, str):
  +        colour = colour if colour.startswith("#") else f"#{colour}"
  +    else:
  +        colour = f"#{colour:0>6X}"
       return colour if colour != "#000000" else "#FFFFFF"
  
verification_info: {"golden_diff": "diff --git a/pydis_site/apps/staff/templatetags/deletedmessage_filters.py b/pydis_site/apps/staff/templatetags/deletedmessage_filters.py\n--- a/pydis_site/apps/staff/templatetags/deletedmessage_filters.py\n+++ b/pydis_site/apps/staff/templatetags/deletedmessage_filters.py\n@@ -1,4 +1,5 @@\n from datetime import datetime\n+from typing import Union\n \n from django import template\n \n@@ -6,13 +7,16 @@\n \n \n @register.filter\n-def hex_colour(color: int) -> str:\n+def hex_colour(colour: Union[str, int]) -> str:\n     \"\"\"\n-    Converts an integer representation of a colour to the RGB hex value.\n+    Converts the given representation of a colour to its RGB hex string.\n \n     As we are using a Discord dark theme analogue, black colours are returned as white instead.\n     \"\"\"\n-    colour = f\"#{color:0>6X}\"\n+    if isinstance(colour, str):\n+        colour = colour if colour.startswith(\"#\") else f\"#{colour}\"\n+    else:\n+        colour = f\"#{colour:0>6X}\"\n     return colour if colour != \"#000000\" else \"#FFFFFF\"\n", "issue": "ValueError: Unknown format code 'X' for object of type 'str'\nSentry Issue: [SITE-25](https://sentry.io/organizations/python-discord/issues/3211854811/?referrer=github_integration)\n\n```\nValueError: Unknown format code 'X' for object of type 'str'\n(16 additional frame(s) were not displayed)\n...\n  File \"django/template/defaulttags.py\", line 211, in render\n    nodelist.append(node.render_annotated(context))\n  File \"django/template/base.py\", line 905, in render_annotated\n    return self.render(context)\n  File \"django/template/base.py\", line 988, in render\n    output = self.filter_expression.resolve(context)\n  File \"django/template/base.py\", line 698, in resolve\n    new_obj = func(obj, *arg_vals)\n  File \"pydis_site/apps/staff/templatetags/deletedmessage_filters.py\", line 15, in hex_colour\n    colour = f\"#{color:0>6X}\"\n```\n", "before_files": [{"content": "from datetime import datetime\n\nfrom django import template\n\nregister = template.Library()\n\n\n@register.filter\ndef hex_colour(color: int) -> str:\n    \"\"\"\n    Converts an integer representation of a colour to the RGB hex value.\n\n    As we are using a Discord dark theme analogue, black colours are returned as white instead.\n    \"\"\"\n    colour = f\"#{color:0>6X}\"\n    return colour if colour != \"#000000\" else \"#FFFFFF\"\n\n\n@register.filter\ndef footer_datetime(timestamp: str) -> datetime:\n    \"\"\"Takes an embed timestamp and returns a timezone-aware datetime object.\"\"\"\n    return datetime.fromisoformat(timestamp)\n\n\n@register.filter\ndef visible_newlines(text: str) -> str:\n    \"\"\"Takes an embed timestamp and returns a timezone-aware datetime object.\"\"\"\n    return text.replace(\"\\n\", \" <span class='has-text-grey'>\u21b5</span><br>\")\n", "path": "pydis_site/apps/staff/templatetags/deletedmessage_filters.py"}]}