prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Webknossos CLI download annotation
  ## Context
  - Affected library: webknossos
  When using the webknossos CLI to download an annotation, the download command is overloaded to take care of dataset downloads and annotation downloads. An annotation should be downloaded when no dataset is found. This is triggered by an AssertionError. Currently no assertion is thrown. Instead, an UnexpectedStatusError is raised.
  
  ## Expected Behavior
  When a URL to an Annotation is given, the Annotation should be downloaded.
  
  
  
  </issue>
  <code>
  [start of webknossos/webknossos/cli/download.py]
  1 """This module takes care of downloading WEBKNOSSOS datasets."""
  2 
  3 from typing import Any, List, Optional
  4 
  5 import typer
  6 from typing_extensions import Annotated
  7 
  8 from ..annotation import Annotation
  9 from ..client import webknossos_context
  10 from ..dataset import Dataset
  11 from ..geometry import BoundingBox, Mag
  12 from ._utils import parse_bbox, parse_mag, parse_path
  13 
  14 
  15 def main(
  16     *,
  17     target: Annotated[
  18         Any,
  19         typer.Argument(
  20             show_default=False,
  21             help="Path to save your WEBKNOSSOS dataset.",
  22             parser=parse_path,
  23         ),
  24     ],
  25     url: Annotated[
  26         str,
  27         typer.Option(
  28             help="URL of your dataset or your annotation.",
  29         ),
  30     ],
  31     token: Annotated[
  32         Optional[str],
  33         typer.Option(
  34             help="Authentication token for WEBKNOSSOS instance "
  35             "(https://webknossos.org/auth/token).",
  36             rich_help_panel="WEBKNOSSOS context",
  37             envvar="WK_TOKEN",
  38         ),
  39     ] = None,
  40     bbox: Annotated[
  41         Optional[BoundingBox],
  42         typer.Option(
  43             rich_help_panel="Partial download",
  44             help="Bounding box that should be downloaded. "
  45             "The input format is x,y,z,width,height,depth. "
  46             "Should be a comma separated string (e.g. 0,0,0,10,10,10).",
  47             parser=parse_bbox,
  48             metavar="BBOX",
  49         ),
  50     ] = None,
  51     layer: Annotated[
  52         Optional[List[str]],
  53         typer.Option(
  54             rich_help_panel="Partial download",
  55             help="Layers that should be downloaded. "
  56             "For multiple layers type: --layer color --layer segmentation",
  57         ),
  58     ] = None,
  59     mag: Annotated[
  60         Optional[List[Mag]],
  61         typer.Option(
  62             rich_help_panel="Partial download",
  63             help="Mags that should be downloaded. "
  64             "Should be number or minus separated string (e.g. 2 or 2-2-2). "
  65             "For multiple mags type: --mag 1 --mag 2",
  66             parser=parse_mag,
  67             metavar="MAG",
  68         ),
  69     ] = None,
  70 ) -> None:
  71     """Download a dataset from a WEBKNOSSOS server."""
  72 
  73     layers = layer if layer else None
  74     mags = mag if mag else None
  75 
  76     with webknossos_context(token=token):
  77         try:
  78             Dataset.download(
  79                 dataset_name_or_url=url,
  80                 path=target,
  81                 bbox=bbox,
  82                 layers=layers,
  83                 mags=mags,
  84             )
  85         except AssertionError:
  86             Annotation.download(annotation_id_or_url=url).save(target)
  87
  [end of webknossos/webknossos/cli/download.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/webknossos/webknossos/cli/download.py b/webknossos/webknossos/cli/download.py
  --- a/webknossos/webknossos/cli/download.py
  +++ b/webknossos/webknossos/cli/download.py
  @@ -1,13 +1,15 @@
   """This module takes care of downloading WEBKNOSSOS datasets."""
   
  +import re
   from typing import Any, List, Optional
   
   import typer
   from typing_extensions import Annotated
   
  -from ..annotation import Annotation
  +from ..annotation.annotation import _ANNOTATION_URL_REGEX, Annotation
   from ..client import webknossos_context
  -from ..dataset import Dataset
  +from ..client._resolve_short_link import resolve_short_link
  +from ..dataset.dataset import _DATASET_URL_REGEX, Dataset
   from ..geometry import BoundingBox, Mag
   from ._utils import parse_bbox, parse_mag, parse_path
   
  @@ -72,9 +74,10 @@
   
       layers = layer if layer else None
       mags = mag if mag else None
  +    url = resolve_short_link(url)
   
       with webknossos_context(token=token):
  -        try:
  +        if re.match(_DATASET_URL_REGEX, url):
               Dataset.download(
                   dataset_name_or_url=url,
                   path=target,
  @@ -82,5 +85,13 @@
                   layers=layers,
                   mags=mags,
               )
  -        except AssertionError:
  +        elif re.match(_ANNOTATION_URL_REGEX, url):
               Annotation.download(annotation_id_or_url=url).save(target)
  +        else:
  +            raise RuntimeError(
  +                "The provided URL does not lead to a dataset or annotation."
  +            )
  +
  +
  +if __name__ == "__main__":
  +    typer.run(main)
  
verification_info: {"golden_diff": "diff --git a/webknossos/webknossos/cli/download.py b/webknossos/webknossos/cli/download.py\n--- a/webknossos/webknossos/cli/download.py\n+++ b/webknossos/webknossos/cli/download.py\n@@ -1,13 +1,15 @@\n \"\"\"This module takes care of downloading WEBKNOSSOS datasets.\"\"\"\n \n+import re\n from typing import Any, List, Optional\n \n import typer\n from typing_extensions import Annotated\n \n-from ..annotation import Annotation\n+from ..annotation.annotation import _ANNOTATION_URL_REGEX, Annotation\n from ..client import webknossos_context\n-from ..dataset import Dataset\n+from ..client._resolve_short_link import resolve_short_link\n+from ..dataset.dataset import _DATASET_URL_REGEX, Dataset\n from ..geometry import BoundingBox, Mag\n from ._utils import parse_bbox, parse_mag, parse_path\n \n@@ -72,9 +74,10 @@\n \n     layers = layer if layer else None\n     mags = mag if mag else None\n+    url = resolve_short_link(url)\n \n     with webknossos_context(token=token):\n-        try:\n+        if re.match(_DATASET_URL_REGEX, url):\n             Dataset.download(\n                 dataset_name_or_url=url,\n                 path=target,\n@@ -82,5 +85,13 @@\n                 layers=layers,\n                 mags=mags,\n             )\n-        except AssertionError:\n+        elif re.match(_ANNOTATION_URL_REGEX, url):\n             Annotation.download(annotation_id_or_url=url).save(target)\n+        else:\n+            raise RuntimeError(\n+                \"The provided URL does not lead to a dataset or annotation.\"\n+            )\n+\n+\n+if __name__ == \"__main__\":\n+    typer.run(main)\n", "issue": "Webknossos CLI download annotation\n## Context\r\n- Affected library: webknossos\r\nWhen using the webknossos CLI to download an annotation, the download command is overloaded to take care of dataset downloads and annotation downloads. An annotation should be downloaded when no dataset is found. This is triggered by an AssertionError. Currently no assertion is thrown. Instead, an UnexpectedStatusError is raised.\r\n\r\n## Expected Behavior\r\nWhen a URL to an Annotation is given, the Annotation should be downloaded.\r\n\r\n\n", "before_files": [{"content": "\"\"\"This module takes care of downloading WEBKNOSSOS datasets.\"\"\"\n\nfrom typing import Any, List, Optional\n\nimport typer\nfrom typing_extensions import Annotated\n\nfrom ..annotation import Annotation\nfrom ..client import webknossos_context\nfrom ..dataset import Dataset\nfrom ..geometry import BoundingBox, Mag\nfrom ._utils import parse_bbox, parse_mag, parse_path\n\n\ndef main(\n    *,\n    target: Annotated[\n        Any,\n        typer.Argument(\n            show_default=False,\n            help=\"Path to save your WEBKNOSSOS dataset.\",\n            parser=parse_path,\n        ),\n    ],\n    url: Annotated[\n        str,\n        typer.Option(\n            help=\"URL of your dataset or your annotation.\",\n        ),\n    ],\n    token: Annotated[\n        Optional[str],\n        typer.Option(\n            help=\"Authentication token for WEBKNOSSOS instance \"\n            \"(https://webknossos.org/auth/token).\",\n            rich_help_panel=\"WEBKNOSSOS context\",\n            envvar=\"WK_TOKEN\",\n        ),\n    ] = None,\n    bbox: Annotated[\n        Optional[BoundingBox],\n        typer.Option(\n            rich_help_panel=\"Partial download\",\n            help=\"Bounding box that should be downloaded. \"\n            \"The input format is x,y,z,width,height,depth. \"\n            \"Should be a comma separated string (e.g. 0,0,0,10,10,10).\",\n            parser=parse_bbox,\n            metavar=\"BBOX\",\n        ),\n    ] = None,\n    layer: Annotated[\n        Optional[List[str]],\n        typer.Option(\n            rich_help_panel=\"Partial download\",\n            help=\"Layers that should be downloaded. \"\n            \"For multiple layers type: --layer color --layer segmentation\",\n        ),\n    ] = None,\n    mag: Annotated[\n        Optional[List[Mag]],\n        typer.Option(\n            rich_help_panel=\"Partial download\",\n            help=\"Mags that should be downloaded. \"\n            \"Should be number or minus separated string (e.g. 2 or 2-2-2). \"\n            \"For multiple mags type: --mag 1 --mag 2\",\n            parser=parse_mag,\n            metavar=\"MAG\",\n        ),\n    ] = None,\n) -> None:\n    \"\"\"Download a dataset from a WEBKNOSSOS server.\"\"\"\n\n    layers = layer if layer else None\n    mags = mag if mag else None\n\n    with webknossos_context(token=token):\n        try:\n            Dataset.download(\n                dataset_name_or_url=url,\n                path=target,\n                bbox=bbox,\n                layers=layers,\n                mags=mags,\n            )\n        except AssertionError:\n            Annotation.download(annotation_id_or_url=url).save(target)\n", "path": "webknossos/webknossos/cli/download.py"}]}