prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Not using HA supported python version
  HA supports the last two minor versions of Python, that is currently 3.10 and 3.9.
  [calendar.py](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/custom_components/waste_collection_schedule/calendar.py#L118) makes use of Python 3.10 only type hinting features for optional arguments via unions:
  `def calc_unique_calendar_id(scraper: Scraper, type: str | None = None):`
  The union str | None is not supported as type hint by Python 3.9, hence the waste collection schedule fails to load albeit HA runs on a supported installation.
  
  </issue>
  <code>
  [start of custom_components/waste_collection_schedule/calendar.py]
  1 """Calendar platform support for Waste Collection Schedule."""
  2 
  3 import logging
  4 from datetime import timedelta, timezone, datetime
  5 
  6 from homeassistant.components.calendar import CalendarEntity, CalendarEvent
  7 from homeassistant.core import HomeAssistant
  8 from homeassistant.util.dt import DEFAULT_TIME_ZONE
  9 
  10 from custom_components.waste_collection_schedule.waste_collection_schedule.scraper import (
  11     Scraper,
  12 )
  13 
  14 _LOGGER = logging.getLogger(__name__)
  15 
  16 
  17 async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
  18     """Set up calendar platform."""
  19     # We only want this platform to be set up via discovery.
  20     if discovery_info is None:
  21         return
  22 
  23     entities = []
  24 
  25     api = discovery_info["api"]
  26 
  27     for scraper in api.scrapers:
  28         dedicated_calendar_types = scraper.get_dedicated_calendar_types()
  29         global_calendar_types = scraper.get_global_calendar_types()
  30 
  31         if dedicated_calendar_types is not None:
  32             for type in dedicated_calendar_types:
  33                 unique_id = calc_unique_calendar_id(scraper, type)
  34 
  35                 entities.append(
  36                     WasteCollectionCalendar(
  37                         api,
  38                         scraper,
  39                         scraper.get_calendar_title_for_type(type),
  40                         [scraper.get_collection_type(type)],
  41                         unique_id,
  42                     )
  43                 )
  44 
  45         if global_calendar_types is not None or dedicated_calendar_types is None:
  46             unique_id = calc_unique_calendar_id(scraper)
  47             entities.append(
  48                 WasteCollectionCalendar(
  49                     api,
  50                     scraper,
  51                     scraper.calendar_title,
  52                     [
  53                         scraper.get_collection_type(type)
  54                         for type in global_calendar_types
  55                     ]
  56                     if global_calendar_types is not None
  57                     else None,
  58                     unique_id,
  59                 )
  60             )
  61 
  62     async_add_entities(entities)
  63 
  64 
  65 class WasteCollectionCalendar(CalendarEntity):
  66     """Calendar entity class."""
  67 
  68     def __init__(self, api, scraper, name, types, unique_id: str):
  69         self._api = api
  70         self._scraper = scraper
  71         self._name = name
  72         self._types = types
  73         self._unique_id = unique_id
  74         self._attr_unique_id = unique_id
  75 
  76     @property
  77     def name(self):
  78         """Return entity name."""
  79         return self._name
  80 
  81     @property
  82     def event(self):
  83         """Return next collection event."""
  84         collections = self._scraper.get_upcoming(
  85             count=1, include_today=True, types=self._types
  86         )
  87 
  88         if len(collections) == 0:
  89             return None
  90         else:
  91             return self._convert(collections[0])
  92 
  93     async def async_get_events(
  94         self, hass: HomeAssistant, start_date: datetime, end_date: datetime
  95     ):
  96         """Return all events within specified time span."""
  97         events = []
  98 
  99         for collection in self._scraper.get_upcoming(
  100             include_today=True, types=self._types
  101         ):
  102             event = self._convert(collection)
  103 
  104             if start_date <= event.start_datetime_local <= end_date:
  105                 events.append(event)
  106 
  107         return events
  108 
  109     def _convert(self, collection) -> CalendarEvent:
  110         """Convert an collection into a Home Assistant calendar event."""
  111         return CalendarEvent(
  112             summary=collection.type,
  113             start=collection.date,
  114             end=collection.date + timedelta(days=1),
  115         )
  116 
  117 
  118 def calc_unique_calendar_id(scraper: Scraper, type: str | None = None):
  119     return scraper.unique_id + ("_" + type if type is not None else "") + "_calendar"
  120
  [end of custom_components/waste_collection_schedule/calendar.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/calendar.py b/custom_components/waste_collection_schedule/calendar.py
  --- a/custom_components/waste_collection_schedule/calendar.py
  +++ b/custom_components/waste_collection_schedule/calendar.py
  @@ -1,15 +1,12 @@
   """Calendar platform support for Waste Collection Schedule."""
   
   import logging
  -from datetime import timedelta, timezone, datetime
  +from datetime import datetime, timedelta
   
   from homeassistant.components.calendar import CalendarEntity, CalendarEvent
   from homeassistant.core import HomeAssistant
  -from homeassistant.util.dt import DEFAULT_TIME_ZONE
   
  -from custom_components.waste_collection_schedule.waste_collection_schedule.scraper import (
  -    Scraper,
  -)
  +from custom_components.waste_collection_schedule.waste_collection_schedule.scraper import Scraper
   
   _LOGGER = logging.getLogger(__name__)
   
  @@ -115,5 +112,5 @@
           )
   
   
  -def calc_unique_calendar_id(scraper: Scraper, type: str | None = None):
  +def calc_unique_calendar_id(scraper: Scraper, type: str = None):
       return scraper.unique_id + ("_" + type if type is not None else "") + "_calendar"
  
verification_info: {"golden_diff": "diff --git a/custom_components/waste_collection_schedule/calendar.py b/custom_components/waste_collection_schedule/calendar.py\n--- a/custom_components/waste_collection_schedule/calendar.py\n+++ b/custom_components/waste_collection_schedule/calendar.py\n@@ -1,15 +1,12 @@\n \"\"\"Calendar platform support for Waste Collection Schedule.\"\"\"\n \n import logging\n-from datetime import timedelta, timezone, datetime\n+from datetime import datetime, timedelta\n \n from homeassistant.components.calendar import CalendarEntity, CalendarEvent\n from homeassistant.core import HomeAssistant\n-from homeassistant.util.dt import DEFAULT_TIME_ZONE\n \n-from custom_components.waste_collection_schedule.waste_collection_schedule.scraper import (\n-    Scraper,\n-)\n+from custom_components.waste_collection_schedule.waste_collection_schedule.scraper import Scraper\n \n _LOGGER = logging.getLogger(__name__)\n \n@@ -115,5 +112,5 @@\n         )\n \n \n-def calc_unique_calendar_id(scraper: Scraper, type: str | None = None):\n+def calc_unique_calendar_id(scraper: Scraper, type: str = None):\n     return scraper.unique_id + (\"_\" + type if type is not None else \"\") + \"_calendar\"\n", "issue": "Not using HA supported python version\nHA supports the last two minor versions of Python, that is currently 3.10 and 3.9.\r\n[calendar.py](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/custom_components/waste_collection_schedule/calendar.py#L118) makes use of Python 3.10 only type hinting features for optional arguments via unions:\r\n`def calc_unique_calendar_id(scraper: Scraper, type: str | None = None):`\r\nThe union str | None is not supported as type hint by Python 3.9, hence the waste collection schedule fails to load albeit HA runs on a supported installation.\n", "before_files": [{"content": "\"\"\"Calendar platform support for Waste Collection Schedule.\"\"\"\n\nimport logging\nfrom datetime import timedelta, timezone, datetime\n\nfrom homeassistant.components.calendar import CalendarEntity, CalendarEvent\nfrom homeassistant.core import HomeAssistant\nfrom homeassistant.util.dt import DEFAULT_TIME_ZONE\n\nfrom custom_components.waste_collection_schedule.waste_collection_schedule.scraper import (\n    Scraper,\n)\n\n_LOGGER = logging.getLogger(__name__)\n\n\nasync def async_setup_platform(hass, config, async_add_entities, discovery_info=None):\n    \"\"\"Set up calendar platform.\"\"\"\n    # We only want this platform to be set up via discovery.\n    if discovery_info is None:\n        return\n\n    entities = []\n\n    api = discovery_info[\"api\"]\n\n    for scraper in api.scrapers:\n        dedicated_calendar_types = scraper.get_dedicated_calendar_types()\n        global_calendar_types = scraper.get_global_calendar_types()\n\n        if dedicated_calendar_types is not None:\n            for type in dedicated_calendar_types:\n                unique_id = calc_unique_calendar_id(scraper, type)\n\n                entities.append(\n                    WasteCollectionCalendar(\n                        api,\n                        scraper,\n                        scraper.get_calendar_title_for_type(type),\n                        [scraper.get_collection_type(type)],\n                        unique_id,\n                    )\n                )\n\n        if global_calendar_types is not None or dedicated_calendar_types is None:\n            unique_id = calc_unique_calendar_id(scraper)\n            entities.append(\n                WasteCollectionCalendar(\n                    api,\n                    scraper,\n                    scraper.calendar_title,\n                    [\n                        scraper.get_collection_type(type)\n                        for type in global_calendar_types\n                    ]\n                    if global_calendar_types is not None\n                    else None,\n                    unique_id,\n                )\n            )\n\n    async_add_entities(entities)\n\n\nclass WasteCollectionCalendar(CalendarEntity):\n    \"\"\"Calendar entity class.\"\"\"\n\n    def __init__(self, api, scraper, name, types, unique_id: str):\n        self._api = api\n        self._scraper = scraper\n        self._name = name\n        self._types = types\n        self._unique_id = unique_id\n        self._attr_unique_id = unique_id\n\n    @property\n    def name(self):\n        \"\"\"Return entity name.\"\"\"\n        return self._name\n\n    @property\n    def event(self):\n        \"\"\"Return next collection event.\"\"\"\n        collections = self._scraper.get_upcoming(\n            count=1, include_today=True, types=self._types\n        )\n\n        if len(collections) == 0:\n            return None\n        else:\n            return self._convert(collections[0])\n\n    async def async_get_events(\n        self, hass: HomeAssistant, start_date: datetime, end_date: datetime\n    ):\n        \"\"\"Return all events within specified time span.\"\"\"\n        events = []\n\n        for collection in self._scraper.get_upcoming(\n            include_today=True, types=self._types\n        ):\n            event = self._convert(collection)\n\n            if start_date <= event.start_datetime_local <= end_date:\n                events.append(event)\n\n        return events\n\n    def _convert(self, collection) -> CalendarEvent:\n        \"\"\"Convert an collection into a Home Assistant calendar event.\"\"\"\n        return CalendarEvent(\n            summary=collection.type,\n            start=collection.date,\n            end=collection.date + timedelta(days=1),\n        )\n\n\ndef calc_unique_calendar_id(scraper: Scraper, type: str | None = None):\n    return scraper.unique_id + (\"_\" + type if type is not None else \"\") + \"_calendar\"\n", "path": "custom_components/waste_collection_schedule/calendar.py"}]}