prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Braintree error when selecting address
  I have had the follow error for the past couple of months:
  
  > fetch failed for source Braintree District Council: Traceback (most recent call last): File "/config/custom_components/waste_collection_schedule/waste_collection_schedule/source_shell.py", line 134, in fetch entries = self._source.fetch() ^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/waste_collection_schedule/waste_collection_schedule/source/braintree_gov_uk.py", line 45, in fetch id = next( ^^^^^ StopIteration
  
  I am seeing address["value"] on line 43 having a length of 11.
  Removing this line cures the problem for me, and I am not sure what this line is achieving?
  
  https://github.com/mampfes/hacs_waste_collection_schedule/blob/73baeef472c5db4c85db3a7b725df68f3a15a101/custom_components/waste_collection_schedule/waste_collection_schedule/source/braintree_gov_uk.py#L43
  
  </issue>
  <code>
  [start of custom_components/waste_collection_schedule/waste_collection_schedule/source/braintree_gov_uk.py]
  1 import requests
  2 from bs4 import BeautifulSoup
  3 from dateutil import parser
  4 from waste_collection_schedule import Collection
  5 
  6 TITLE = "Braintree District Council"
  7 DESCRIPTION = "Braintree District Council, UK - Waste Collection"
  8 URL = "https://www.braintree.gov.uk"
  9 TEST_CASES = {
  10     "30 Boars Tye Road": {"house_number": "30", "post_code": "CM8 3QE"},
  11     "64 Silver Street": {"house_number": "64", "post_code": "CM8 3QG"},
  12     "18 St Mary's Road": {"house_number": "1", "post_code": "CM8 3PE"},
  13     "20 Peel Crescent": {"house_number": "20", "post_code": "CM7 2RS"},
  14 }
  15 
  16 ICON_MAP = {
  17     "Grey Bin": "mdi:trash-can",
  18     "Clear Sack": "mdi:recycle",
  19     "Green Bin": "mdi:leaf",
  20     "Food Bin": "mdi:food-apple",
  21 }
  22 
  23 
  24 class Source:
  25     def __init__(self, post_code: str, house_number: str):
  26         self.post_code = post_code
  27         self.house_number = house_number
  28         self.url = f"{URL}/xfp/form/554"
  29         self.form_data = {
  30             "qe15dda0155d237d1ea161004d1839e3369ed4831_0_0": (None, post_code),
  31             "page": (None, 5730),
  32         }
  33 
  34     def fetch(self):
  35         address_lookup = requests.post(
  36             "https://www.braintree.gov.uk/xfp/form/554", files=self.form_data
  37         )
  38         address_lookup.raise_for_status()
  39         addresses = {}
  40         for address in BeautifulSoup(address_lookup.text, "html.parser").find_all(
  41             "option"
  42         ):
  43             if len(address["value"]) == 12:
  44                 addresses[address["value"]] = address.text.strip()
  45         id = next(
  46             address
  47             for address in addresses
  48             if addresses[address].startswith(self.house_number)
  49         )
  50         self.form_data["qe15dda0155d237d1ea161004d1839e3369ed4831_1_0"] = (None, id)
  51         self.form_data["next"] = (None, "Next")
  52         collection_lookup = requests.post(
  53             "https://www.braintree.gov.uk/xfp/form/554", files=self.form_data
  54         )
  55         collection_lookup.raise_for_status()
  56         entries = []
  57         for results in BeautifulSoup(collection_lookup.text, "html.parser").find_all(
  58             "div", class_="date_display"
  59         ):
  60             try:
  61                 collection_type, collection_date = results.text.strip().split("\n")
  62                 entries.append(
  63                     Collection(
  64                         date=parser.parse(collection_date, dayfirst=True).date(),
  65                         t=collection_type,
  66                         icon=ICON_MAP.get(collection_type),
  67                     )
  68                 )
  69             except (StopIteration, TypeError):
  70                 pass
  71         return entries
  72
  [end of custom_components/waste_collection_schedule/waste_collection_schedule/source/braintree_gov_uk.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/custom_components/waste_collection_schedule/waste_collection_schedule/source/braintree_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/braintree_gov_uk.py
  --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/braintree_gov_uk.py
  +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/braintree_gov_uk.py
  @@ -1,7 +1,7 @@
   import requests
   from bs4 import BeautifulSoup
   from dateutil import parser
  -from waste_collection_schedule import Collection
  +from waste_collection_schedule import Collection  # type: ignore[attr-defined]
   
   TITLE = "Braintree District Council"
   DESCRIPTION = "Braintree District Council, UK - Waste Collection"
  @@ -40,7 +40,7 @@
           for address in BeautifulSoup(address_lookup.text, "html.parser").find_all(
               "option"
           ):
  -            if len(address["value"]) == 12:
  +            if len(address["value"]) > 5:  # Skip the first option
                   addresses[address["value"]] = address.text.strip()
           id = next(
               address
  
verification_info: {"golden_diff": "diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/braintree_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/braintree_gov_uk.py\n--- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/braintree_gov_uk.py\n+++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/braintree_gov_uk.py\n@@ -1,7 +1,7 @@\n import requests\n from bs4 import BeautifulSoup\n from dateutil import parser\n-from waste_collection_schedule import Collection\n+from waste_collection_schedule import Collection  # type: ignore[attr-defined]\n \n TITLE = \"Braintree District Council\"\n DESCRIPTION = \"Braintree District Council, UK - Waste Collection\"\n@@ -40,7 +40,7 @@\n         for address in BeautifulSoup(address_lookup.text, \"html.parser\").find_all(\n             \"option\"\n         ):\n-            if len(address[\"value\"]) == 12:\n+            if len(address[\"value\"]) > 5:  # Skip the first option\n                 addresses[address[\"value\"]] = address.text.strip()\n         id = next(\n             address\n", "issue": "Braintree error when selecting address\nI have had the follow error for the past couple of months:\r\n\r\n> fetch failed for source Braintree District Council: Traceback (most recent call last): File \"/config/custom_components/waste_collection_schedule/waste_collection_schedule/source_shell.py\", line 134, in fetch entries = self._source.fetch() ^^^^^^^^^^^^^^^^^^^^ File \"/config/custom_components/waste_collection_schedule/waste_collection_schedule/source/braintree_gov_uk.py\", line 45, in fetch id = next( ^^^^^ StopIteration\r\n\r\nI am seeing address[\"value\"] on line 43 having a length of 11.\r\nRemoving this line cures the problem for me, and I am not sure what this line is achieving?\r\n\r\nhttps://github.com/mampfes/hacs_waste_collection_schedule/blob/73baeef472c5db4c85db3a7b725df68f3a15a101/custom_components/waste_collection_schedule/waste_collection_schedule/source/braintree_gov_uk.py#L43\n", "before_files": [{"content": "import requests\nfrom bs4 import BeautifulSoup\nfrom dateutil import parser\nfrom waste_collection_schedule import Collection\n\nTITLE = \"Braintree District Council\"\nDESCRIPTION = \"Braintree District Council, UK - Waste Collection\"\nURL = \"https://www.braintree.gov.uk\"\nTEST_CASES = {\n    \"30 Boars Tye Road\": {\"house_number\": \"30\", \"post_code\": \"CM8 3QE\"},\n    \"64 Silver Street\": {\"house_number\": \"64\", \"post_code\": \"CM8 3QG\"},\n    \"18 St Mary's Road\": {\"house_number\": \"1\", \"post_code\": \"CM8 3PE\"},\n    \"20 Peel Crescent\": {\"house_number\": \"20\", \"post_code\": \"CM7 2RS\"},\n}\n\nICON_MAP = {\n    \"Grey Bin\": \"mdi:trash-can\",\n    \"Clear Sack\": \"mdi:recycle\",\n    \"Green Bin\": \"mdi:leaf\",\n    \"Food Bin\": \"mdi:food-apple\",\n}\n\n\nclass Source:\n    def __init__(self, post_code: str, house_number: str):\n        self.post_code = post_code\n        self.house_number = house_number\n        self.url = f\"{URL}/xfp/form/554\"\n        self.form_data = {\n            \"qe15dda0155d237d1ea161004d1839e3369ed4831_0_0\": (None, post_code),\n            \"page\": (None, 5730),\n        }\n\n    def fetch(self):\n        address_lookup = requests.post(\n            \"https://www.braintree.gov.uk/xfp/form/554\", files=self.form_data\n        )\n        address_lookup.raise_for_status()\n        addresses = {}\n        for address in BeautifulSoup(address_lookup.text, \"html.parser\").find_all(\n            \"option\"\n        ):\n            if len(address[\"value\"]) == 12:\n                addresses[address[\"value\"]] = address.text.strip()\n        id = next(\n            address\n            for address in addresses\n            if addresses[address].startswith(self.house_number)\n        )\n        self.form_data[\"qe15dda0155d237d1ea161004d1839e3369ed4831_1_0\"] = (None, id)\n        self.form_data[\"next\"] = (None, \"Next\")\n        collection_lookup = requests.post(\n            \"https://www.braintree.gov.uk/xfp/form/554\", files=self.form_data\n        )\n        collection_lookup.raise_for_status()\n        entries = []\n        for results in BeautifulSoup(collection_lookup.text, \"html.parser\").find_all(\n            \"div\", class_=\"date_display\"\n        ):\n            try:\n                collection_type, collection_date = results.text.strip().split(\"\\n\")\n                entries.append(\n                    Collection(\n                        date=parser.parse(collection_date, dayfirst=True).date(),\n                        t=collection_type,\n                        icon=ICON_MAP.get(collection_type),\n                    )\n                )\n            except (StopIteration, TypeError):\n                pass\n        return entries\n", "path": "custom_components/waste_collection_schedule/waste_collection_schedule/source/braintree_gov_uk.py"}]}