core icon indicating copy to clipboard operation
core copied to clipboard

Bump python-telegram-bot package to 20.8

Open malkstar opened this issue 1 year ago • 9 comments

Proposed change

The python-telegram-bot package is quite outdated. There is now native async support and it uses httpx instead of urllib3.

This is mostly refactors related to that and various namespace changes. The main namespace change is from Dispatcher to Application and the async changes around this class specifically.

I couldn't refactor test_polling_platform_message_text_update to work effectively now it's no longer possible to get the instance of a running Application object. If anyone could suggest how to get the PollBot or Application instance created in async_setup_platform I should be able to re-add the test.

The timeout kwarg has been broken out into three, read_timeout, write_timeout and connect_timeout. ~I picked connect_timeout based on the current documentation indicating it was to get around flakey internet.~ I dug into the way the library uses this and it is actually a read timeout. The rest could of course be added to config options if it seemed useful.

I believe the proxy_params config can now be deprecated, as the httpx.Proxy object supports username and password directly in the proxy URL. I'm unsure of other options that are currently passed to this, feedback welcome.

PySocks is no longer required, in favour of pip installing the socks version of the library and using the support in httpx directly.

As a bonus I also refactored the load_data function to use httpx instead of requests.

Appreciate any feedback on this one, it's a bigger change than I thought when I originally started looking at it.

Full changelog: https://docs.python-telegram-bot.org/en/v20.8/changelog.html Transition guide: https://github.com/python-telegram-bot/python-telegram-bot/wiki/Transition-guide-to-Version-20.0

Type of change

  • [x] Dependency upgrade
  • [ ] Bugfix (non-breaking change which fixes an issue)
  • [ ] New integration (thank you!)
  • [ ] New feature (which adds functionality to an existing integration)
  • [ ] Deprecation (breaking change to happen in the future)
  • [ ] Breaking change (fix/feature causing existing functionality to break)
  • [ ] Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #109263 #107942
  • This PR is related to issue:
  • Link to documentation pull request:

Holding up: https://github.com/home-assistant/core/pull/104059

Checklist

  • [x] The code change is tested and works locally.
  • [x] Local tests pass. Your PR cannot be merged unless tests pass
  • [x] There is no commented out code in this PR.
  • [x] I have followed the development checklist
  • [x] I have followed the perfect PR recommendations
  • [x] The code has been formatted using Ruff (ruff format homeassistant tests)
  • [ ] Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • [x] The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • [x] New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • [x] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • [ ] Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

malkstar avatar Feb 11 '24 22:02 malkstar

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks :+1:

Learn more about our pull request process.

home-assistant[bot] avatar Feb 12 '24 09:02 home-assistant[bot]

Thanks for the PR @malkstar Once this is merged, I can re-submit the topics PR #104059. I was working on it today, but found out it needs fixing telegram library first for compatibility.

r-xyz avatar Feb 13 '24 13:02 r-xyz

@r-xyz I noticed when testing some other changes that there are in fact loads of breaking changes that weren't listed in the other PR, likely related to the abandonment. Appreciate you keeping on top of getting that over the line.

I just need to test webhooks before marking ready for review again, which means installing in a proper environment.

Appreciate your input @MartinHjelmare.

malkstar avatar Feb 13 '24 18:02 malkstar

@malkstar I use webhooks. I gladly start testing this installing it as a custom component in my environment if it can be of any help.

luca-angemi avatar Feb 13 '24 18:02 luca-angemi

@malkstar I use webhooks. I gladly start testing this installing it as a custom component in my environment if it can be of any help.

Would appreciate that, I just did a quick test and it worked for me after a small change.

If you could use the latest version and see how it goes, I'm now running it in production.

malkstar avatar Feb 13 '24 20:02 malkstar

Tested with read timeout. Works perfectly. I've tested sending messages, photo, video, documents and receiving command & text events.

luca-angemi avatar Feb 13 '24 21:02 luca-angemi

There's a mypy failure that we need to solve too.

Run . venv/bin/activate
Python 3.11.8
Error: venv/lib/python3.11/site-packages/tenacity/tornadoweb.py:23: error: Cannot find implementation or library stub for module named "tornado.gen"  [import-not-found]
Error: venv/lib/python3.11/site-packages/tenacity/tornadoweb.py:23: error: Cannot find implementation or library stub for module named "tornado"  [import-not-found]
Error: venv/lib/python3.11/site-packages/tenacity/tornadoweb.py:26: error: Cannot find implementation or library stub for module named "tornado.concurrent"  [import-not-found]
Error: venv/lib/python3.11/site-packages/tenacity/__init__.py:83: error: Cannot find implementation or library stub for module named "tornado"  [import-not-found]
venv/lib/python3.11/site-packages/tenacity/__init__.py:83: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 4 errors in 2 files (checked 6652 source files)
Error: Process completed with exit code 1.

MartinHjelmare avatar Feb 16 '24 09:02 MartinHjelmare

I think we need to add ignore_missing_imports for tenacity in mypy.ini via mypy config. I'll look at that separately.

MartinHjelmare avatar Feb 16 '24 16:02 MartinHjelmare

@MartinHjelmare thank you, I did notice that but thought it was unrelated.

malkstar avatar Feb 16 '24 16:02 malkstar

No need to merge dev branch regularly unless we know we need something from it.

MartinHjelmare avatar Feb 18 '24 16:02 MartinHjelmare

FWIW I don't get any mypy issues locally

malkstar avatar Feb 20 '24 20:02 malkstar

We think the problem is that python telegram bot no longer implicitly requires tornado which makes mypy fail to find that import in tenacity, which is a 3rd party requirement of some libraries of some integrations in Home Assistant.

So there's nothing really wrong in this PR but we still need to fix this problem before we can merge here, since it's a consequence of the bump here. I'll make a PR tomorrow for that.

MartinHjelmare avatar Feb 20 '24 21:02 MartinHjelmare

thank you, appreciate your help with that

malkstar avatar Feb 20 '24 22:02 malkstar

Working on trying to reproduce the mypy failure.

MartinHjelmare avatar Feb 22 '24 08:02 MartinHjelmare

As mentioned above, tornado is only installed optionally. Not sure why the failure, since we are only installing python-telegram-bot[socks].

I tried to reproduce it locally, too, but without luck. I leave my output below in case it might give any insight. I ran them on current PR branch.

Running mypy on telegram_bot only (Success)

 /workspaces/ha_core (bump-python-telegram-bot-package-version) $ mypy homeassistant/components/telegram_bot 
Success: no issues found in 4 source files

Running mypy on all files:

/workspaces/ha_core (bump-python-telegram-bot-package-version) $ mypy homeassistant pylint
mypy: can't read file '/usr/local/lib/python3.11/site-packages//google': No such file or directory
Full result running tests on all files (Fails somewhere else not on telegram_bot)
ha_core (bump-python-telegram-bot-package-version) $ pre-commit run --all-files
[INFO] Initializing environment for https://github.com/astral-sh/ruff-pre-commit.
[INFO] Initializing environment for https://github.com/codespell-project/codespell.
[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Initializing environment for https://github.com/adrienverge/yamllint.git.
[INFO] Initializing environment for https://github.com/pre-commit/mirrors-prettier.
[INFO] Initializing environment for https://github.com/pre-commit/mirrors-prettier:[email protected].
[INFO] Initializing environment for https://github.com/cdce8p/python-typing-update.
[INFO] Installing environment for https://github.com/astral-sh/ruff-pre-commit.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/codespell-project/codespell.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/adrienverge/yamllint.git.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/pre-commit/mirrors-prettier.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
ruff.....................................................................Passed
ruff-format..............................................................Passed
codespell................................................................Passed
check json...............................................................Passed
don't commit to branch...................................................Passed
yamllint.................................................................Passed
prettier.................................................................Passed
mypy.....................................................................Failed
- hook id: mypy
- exit code: 2

mypy: can't read file '/usr/local/lib/python3.11/site-packages//google': No such file or directory
homeassistant/components/owntracks/helper.py:5: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/ssdp/__init__.py:643: error: Class cannot subclass "UpnpServerDevice" (has type "Any")  [misc]
homeassistant/components/tedee/coordinator.py:89: error: Returning Any from function declared to return "dict[int, Any]"  [no-any-return]
homeassistant/components/tailscale/coordinator.py:37: error: Returning Any from function declared to return "dict[str, Any]"  [no-any-return]
homeassistant/components/switchbee/coordinator.py:100: error: Returning Any from function declared to return "Mapping[int, Any]"  [no-any-return]
homeassistant/components/switchbee/config_flow.py:50: error: Returning Any from function declared to return "str"  [no-any-return]
homeassistant/components/surepetcare/__init__.py:133: error: Returning Any from function declared to return "dict[int, Any]"  [no-any-return]
homeassistant/components/steamist/discovery.py:29: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/sonarr/coordinator.py:110: error: Returning Any from function declared to return "list[Any]"  [no-any-return]
homeassistant/components/snooz/config_flow.py:195: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/simplisafe/__init__.py:271: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/shelly/utils.py:112: error: Returning Any from function declared to return "str"  [no-any-return]
homeassistant/components/shelly/utils.py:251: error: Returning Any from function declared to return "WebSocketResponse"  [no-any-return]
homeassistant/components/shelly/utils.py:311: error: Returning Any from function declared to return "str"  [no-any-return]
homeassistant/components/senz/api.py:10: error: Class cannot subclass "AbstractSENZAuth" (has type "Any")  [misc]
homeassistant/components/samsungtv/bridge.py:414: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/samsungtv/bridge.py:425: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/recollect_waste/__init__.py:42: error: Returning Any from function declared to return "list[Any]"  [no-any-return]
homeassistant/components/rainforest_raven/coordinator.py:85: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/rainforest_raven/coordinator.py:92: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/rainforest_raven/coordinator.py:99: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/rainforest_raven/coordinator.py:106: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/rainforest_raven/coordinator.py:113: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/radarr/config_flow.py:117: error: Returning Any from function declared to return "tuple[str, str, str] | None"  [no-any-return]
homeassistant/components/qnap_qsw/coordinator.py:44: error: Returning Any from function declared to return "dict[str, Any]"  [no-any-return]
homeassistant/components/qnap_qsw/coordinator.py:68: error: Returning Any from function declared to return "dict[str, Any]"  [no-any-return]
homeassistant/components/purpleair/coordinator.py:78: error: Returning Any from function declared to return "str"  [no-any-return]
homeassistant/components/overkiz/config_flow.py:414: error: Returning Any from function declared to return "str"  [no-any-return]
homeassistant/components/oncue/entity.py:60: error: Returning Any from function declared to return "str"  [no-any-return]
homeassistant/components/oncue/__init__.py:36: error: Need type annotation for "coordinator"  [var-annotated]
homeassistant/components/nest/api.py:29: error: Class cannot subclass "AbstractAuth" (has type "Any")  [misc]
homeassistant/components/nest/api.py:72: error: Class cannot subclass "AbstractAuth" (has type "Any")  [misc]
homeassistant/components/myuplink/api.py:14: error: Class cannot subclass "AbstractAuth" (has type "Any")  [misc]
homeassistant/components/linear_garage_door/coordinator.py:74: error: Item "None" of "list[dict[str, list[str] | str]] | None" has no attribute "__iter__" (not iterable)  [union-attr]
homeassistant/components/lidarr/coordinator.py:87: error: Returning Any from function declared to return "str"  [no-any-return]
homeassistant/components/lidarr/config_flow.py:111: error: Returning Any from function declared to return "tuple[str, str, str] | None"  [no-any-return]
homeassistant/components/lacrosse_view/coordinator.py:82: error: Returning Any from function declared to return "list[Any]"  [no-any-return]
homeassistant/components/lacrosse_view/config_flow.py:45: error: Returning Any from function declared to return "list[Any]"  [no-any-return]
homeassistant/components/tolo/select.py:46: error: Returning Any from function declared to return "str"  [no-any-return]
homeassistant/components/tolo/light.py:43: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/tolo/fan.py:42: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/tolo/button.py:47: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/tolo/binary_sensor.py:50: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/tolo/binary_sensor.py:72: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/tile/device_tracker.py:126: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/tile/device_tracker.py:133: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/tailwind/diagnostics.py:18: error: Returning Any from function declared to return "dict[str, Any]"  [no-any-return]
homeassistant/components/snooz/fan.py:112: error: Returning Any from function declared to return "Callable[[], None]"  [no-any-return]
homeassistant/components/shelly/coordinator.py:124: error: Returning Any from function declared to return "str"  [no-any-return]
homeassistant/components/recorder/pool.py:57: error: Returning Any from function declared to return "None"  [no-any-return]
homeassistant/components/recorder/pool.py:98: error: Class cannot subclass "StaticPool" (has type "Any")  [misc]
homeassistant/components/radarr/coordinator.py:100: error: Returning Any from function declared to return "list[Any]"  [no-any-return]
homeassistant/components/radarr/coordinator.py:111: error: Returning Any from function declared to return "list[Any]"  [no-any-return]
homeassistant/components/radarr/coordinator.py:127: error: Returning Any from function declared to return "int"  [no-any-return]
homeassistant/components/pvoutput/diagnostics.py:18: error: Returning Any from function declared to return "dict[str, Any]"  [no-any-return]
homeassistant/components/powerwall/__init__.py:259: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/openuv/__init__.py:56: error: Returning Any from function declared to return "dict[str, Any]"  [no-any-return]
homeassistant/components/openexchangerates/sensor.py:67: error: Returning Any from function declared to return "float"  [no-any-return]
homeassistant/components/nanoleaf/light.py:85: error: Returning Any from function declared to return "list[str]"  [no-any-return]
homeassistant/components/nanoleaf/light.py:90: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/local_calendar/calendar.py:199: error: No overload variant of "__sub__" of "datetime" matches argument type "date"  [operator]
homeassistant/components/local_calendar/calendar.py:199: note: Possible overload variants:
homeassistant/components/local_calendar/calendar.py:199: note:     def __sub__(self, timedelta, /) -> datetime
homeassistant/components/local_calendar/calendar.py:199: note:     def __sub__(self, datetime, /) -> timedelta
homeassistant/components/local_calendar/calendar.py:199: note: Both left and right operands are unions
homeassistant/components/tolo/climate.py:74: error: Returning Any from function declared to return "int"  [no-any-return]
homeassistant/components/tolo/climate.py:79: error: Returning Any from function declared to return "int"  [no-any-return]
homeassistant/components/tolo/climate.py:84: error: Returning Any from function declared to return "int"  [no-any-return]
homeassistant/components/tolo/climate.py:89: error: Returning Any from function declared to return "int"  [no-any-return]
homeassistant/components/tedee/lock.py:60: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/tedee/lock.py:65: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/tedee/lock.py:70: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/tedee/lock.py:75: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/tailwind/cover.py:54: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/switchbee/climate.py:174: error: Dict entry 0 has incompatible type "Any": "str | None"; expected "str": "int | str"  [dict-item]
homeassistant/components/stream/core.py:484: error: Call to untyped function <lambda> in typed context  [no-untyped-call]
homeassistant/components/steamist/switch.py:40: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/skybell/light.py:55: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/skybell/light.py:65: error: Returning Any from function declared to return "tuple[int, int, int] | None"  [no-any-return]
homeassistant/components/shelly/entity.py:562: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/shelly/config_flow.py:359: error: Returning Any from function declared to return "dict[str, Any]"  [no-any-return]
homeassistant/components/sfr_box/diagnostics.py:31: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/sfr_box/diagnostics.py:37: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/sfr_box/diagnostics.py:43: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/sfr_box/diagnostics.py:49: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/senz/climate.py:75: error: Returning Any from function declared to return "float"  [no-any-return]
homeassistant/components/senz/climate.py:80: error: Returning Any from function declared to return "float"  [no-any-return]
homeassistant/components/senz/climate.py:85: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/sensibo/climate.py:220: error: Returning Any from function declared to return "int | None"  [no-any-return]
homeassistant/components/sensibo/climate.py:281: error: Returning Any from function declared to return "list[str] | None"  [no-any-return]
homeassistant/components/sensibo/climate.py:294: error: Returning Any from function declared to return "list[str] | None"  [no-any-return]
homeassistant/components/ridwell/switch.py:56: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/ridwell/sensor.py:87: error: Returning Any from function declared to return "date"  [no-any-return]
homeassistant/components/reolink/host.py:444: error: Parameter 1 of Literal[...] cannot be of type "Any"  [valid-type]
homeassistant/components/radarr/__init__.py:99: error: Redundant cast to "StatusDataUpdateCoordinator"  [redundant-cast]
homeassistant/components/powerwall/sensor.py:59: error: Returning Any from function declared to return "float"  [no-any-return]
homeassistant/components/powerwall/sensor.py:64: error: Returning Any from function declared to return "float"  [no-any-return]
homeassistant/components/powerwall/sensor.py:69: error: Returning Any from function declared to return "float"  [no-any-return]
homeassistant/components/powerwall/sensor.py:74: error: Returning Any from function declared to return "float"  [no-any-return]
homeassistant/components/powerwall/sensor.py:364: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/powerwall/sensor.py:384: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/powerwall/config_flow.py:45: error: Returning Any from function declared to return "tuple[Any, str]"  [no-any-return]
homeassistant/components/powerwall/binary_sensor.py:60: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/powerwall/binary_sensor.py:77: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/powerwall/binary_sensor.py:141: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/plugwise/sensor.py:449: error: Returning Any from function declared to return "int | float"  [no-any-return]
homeassistant/components/plugwise/select.py:101: error: Returning Any from function declared to return "str"  [no-any-return]
homeassistant/components/plugwise/binary_sensor.py:125: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/notion/sensor.py:90: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/notion/sensor.py:91: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/notion/binary_sensor.py:143: error: Returning Any from function declared to return "bool | None"  [no-any-return]
homeassistant/components/nest/climate.py:140: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/nest/climate.py:148: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/nest/climate.py:150: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/nest/climate.py:160: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/nest/climate.py:169: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/myuplink/update.py:67: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/myuplink/update.py:72: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/matter/entity.py:178: error: Returning Any from function declared to return "str"  [no-any-return]
homeassistant/components/matter/light.py:126: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/matter/light.py:213: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/litterrobot/update.py:56: error: Returning Any from function declared to return "str"  [no-any-return]
homeassistant/components/litterrobot/update.py:61: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/litterrobot/sensor.py:69: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/litterrobot/select.py:51: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/litterrobot/binary_sensor.py:51: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/litterrobot/binary_sensor.py:69: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/lidarr/sensor.py:163: error: Returning Any from function declared to return "str"  [no-any-return]
homeassistant/components/skybell/camera.py:61: error: Returning Any from function declared to return "bytes | None"  [no-any-return]
homeassistant/components/shelly/cover.py:107: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/shelly/cover.py:115: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/rtsp_to_webrtc/__init__.py:75: error: Returning Any from function declared to return "str"  [no-any-return]
homeassistant/components/recorder/db_schema.py:66: error: Class cannot subclass "DeclarativeBase" (has type "Any")  [misc]
homeassistant/components/recorder/db_schema.py:138: error: Class cannot subclass "DateTime" (has type "Any")  [misc]
homeassistant/components/recorder/db_schema.py:142: error: Class cannot subclass "CHAR" (has type "Any")  [misc]
homeassistant/components/recorder/db_schema.py:146: error: Unused "type: ignore[no-untyped-call]" comment  [unused-ignore]
homeassistant/components/recorder/db_schema.py:147: error: Unused "type: ignore[no-untyped-call]" comment  [unused-ignore]
homeassistant/components/recorder/db_schema.py:153: error: Unused "type: ignore[no-untyped-call]" comment  [unused-ignore]
homeassistant/components/recorder/db_schema.py:159: error: Class cannot subclass "DATETIME" (has type "Any")  [misc]
homeassistant/components/recorder/db_schema.py:167: error: Class cannot subclass "LargeBinary" (has type "Any")  [misc]
homeassistant/components/recorder/db_schema.py:178: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/recorder/db_schema.py:183: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/recorder/db_schema.py:187: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/recorder/db_schema.py:192: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/recorder/db_schema.py:193: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/recorder/db_schema.py:197: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/recorder/db_schema.py:212: error: Class cannot subclass "JSON" (has type "Any")  [misc]
homeassistant/components/recorder/db_schema.py:372: error: Returning Any from function declared to return "int"  [no-any-return]
homeassistant/components/recorder/db_schema.py:532: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/recorder/db_schema.py:597: error: Returning Any from function declared to return "int"  [no-any-return]
homeassistant/components/plugwise/switch.py:94: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/plugwise/number.py:117: error: Returning Any from function declared to return "float"  [no-any-return]
homeassistant/components/plugwise/climate.py:105: error: Returning Any from function declared to return "float"  [no-any-return]
homeassistant/components/plugwise/climate.py:114: error: Returning Any from function declared to return "float"  [no-any-return]
homeassistant/components/plugwise/climate.py:122: error: Returning Any from function declared to return "float"  [no-any-return]
homeassistant/components/plugwise/climate.py:130: error: Returning Any from function declared to return "float"  [no-any-return]
homeassistant/components/plugwise/climate.py:190: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/overkiz/water_heater_entities/hitachi_dhw.py:51: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/overkiz/water_heater_entities/hitachi_dhw.py:61: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py:79: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py:85: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py:104: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py:113: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py:122: error: Returning Any from function declared to return "bool | None"  [no-any-return]
homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py:128: error: Returning Any from function declared to return "bool | None"  [no-any-return]
homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py:138: error: Returning Any from function declared to return "bool | None"  [no-any-return]
homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py:146: error: Returning Any from function declared to return "bool | None"  [no-any-return]
homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py:182: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py:187: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py:198: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py:204: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py:208: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py:219: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py:229: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/overkiz/water_heater_entities/atlantic_pass_apc_dhw.py:80: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/overkiz/water_heater_entities/atlantic_pass_apc_dhw.py:88: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/overkiz/water_heater_entities/atlantic_pass_apc_dhw.py:96: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/overkiz/siren.py:48: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/overkiz/sensor.py:503: error: Returning Any from function declared to return "str | int | float | None"  [no-any-return]
homeassistant/components/overkiz/lock.py:47: error: Returning Any from function declared to return "bool | None"  [no-any-return]
homeassistant/components/overkiz/light.py:61: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/overkiz/cover_entities/generic_cover.py:84: error: Returning Any from function declared to return "bool | None"  [no-any-return]
homeassistant/components/overkiz/climate_entities/valve_heating_temperature_interface.py:94: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/overkiz/climate_entities/somfy_heating_temperature_interface.py:162: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/overkiz/climate_entities/somfy_heating_temperature_interface.py:169: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/overkiz/climate_entities/hitachi_air_to_air_heat_pump_hlrrwifi.py:177: error: Returning Any from function declared to return "int | None"  [no-any-return]
homeassistant/components/overkiz/climate_entities/hitachi_air_to_air_heat_pump_hlrrwifi.py:185: error: Returning Any from function declared to return "int | None"  [no-any-return]
homeassistant/components/overkiz/climate_entities/hitachi_air_to_air_heat_pump_hlrrwifi.py:222: error: Returning Any from function declared to return "str"  [no-any-return]
homeassistant/components/overkiz/climate_entities/atlantic_electrical_heater_with_adjustable_temperature_setpoint.py:139: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/overkiz/climate_entities/atlantic_electrical_heater_with_adjustable_temperature_setpoint.py:146: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/open_meteo/weather.py:74: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/open_meteo/weather.py:81: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/open_meteo/weather.py:88: error: Returning Any from function declared to return "float | str | None"  [no-any-return]
homeassistant/components/nibe_heatpump/number.py:69: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/nest/camera.py:134: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/nest/camera.py:213: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/lamarzocco/number.py:111: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/lamarzocco/number.py:123: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/lamarzocco/number.py:135: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/roku/select.py:37: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/recorder/filters.py:200: error: Unused "type: ignore[no-any-return, no-untyped-call]" comment  [unused-ignore]
homeassistant/components/recorder/filters.py:218: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/recorder/filters.py:228: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/recorder/filters.py:247: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/otbr/util.py:101: error: Returning Any from function declared to return "bytes | None"  [no-any-return]
homeassistant/components/otbr/util.py:108: error: Returning Any from function declared to return "None"  [no-any-return]
homeassistant/components/otbr/util.py:118: error: Returning Any from function declared to return "bytes | None"  [no-any-return]
homeassistant/components/otbr/util.py:123: error: Returning Any from function declared to return "bytes | None"  [no-any-return]
homeassistant/components/otbr/util.py:130: error: Returning Any from function declared to return "None"  [no-any-return]
homeassistant/components/otbr/util.py:135: error: Returning Any from function declared to return "None"  [no-any-return]
homeassistant/components/otbr/util.py:152: error: Returning Any from function declared to return "bytes"  [no-any-return]
homeassistant/components/nest/media_source.py:97: error: Class cannot subclass "EventMediaStore" (has type "Any")  [misc]
homeassistant/components/nest/diagnostics.py:39: error: Returning Any from function declared to return "dict[str, Any]"  [no-any-return]
homeassistant/components/nest/diagnostics.py:72: error: Returning Any from function declared to return "dict[str, Any]"  [no-any-return]
homeassistant/components/recorder/util.py:503: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/recorder/util.py:504: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/recorder/util.py:506: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/recorder/table_managers/statistics_meta.py:61: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/recorder/table_managers/statistics_meta.py:62: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/recorder/table_managers/statistics_meta.py:64: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/recorder/table_managers/statistics_meta.py:65: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/recorder/table_managers/statistics_meta.py:143: error: Returning Any from function declared to return "int"  [no-any-return]
homeassistant/components/recorder/statistics.py:1157: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/recorder/auto_repairs/schema.py:106: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/recorder/migration.py:537: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/recorder/migration.py:544: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/recorder/migration.py:547: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/recorder/migration.py:571: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/recorder/migration.py:1264: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/recorder/migration.py:1295: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/tibber/sensor.py:465: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/roku/browse_media.py:56: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/recorder/history/modern.py:578: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/roku/media_player.py:138: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/roku/media_player.py:183: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/roku/media_player.py:189: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/roku/media_player.py:197: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/roku/media_player.py:218: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/roku/media_player.py:226: error: Returning Any from function declared to return "int | None"  [no-any-return]
homeassistant/components/roku/media_player.py:234: error: Returning Any from function declared to return "int | None"  [no-any-return]
homeassistant/components/roku/media_player.py:242: error: Returning Any from function declared to return "datetime | None"  [no-any-return]
homeassistant/components/roku/media_player.py:250: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/otbr/silabs_multiprotocol.py:74: error: Returning Any from function declared to return "int | None"  [no-any-return]
homeassistant/components/netatmo/api.py:28: error: Class cannot subclass "AbstractAsyncAuth" (has type "Any")  [misc]
Found 240 errors in 118 files (checked 2804 source files)
homeassistant/components/zeroconf/models.py:7: error: Class cannot subclass "Zeroconf" (has type "Any")  [misc]
homeassistant/components/zeroconf/models.py:16: error: Class cannot subclass "AsyncZeroconf" (has type "Any")  [misc]
homeassistant/helpers/network.py:312: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/zeroconf/usage.py:33: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/zeroconf/usage.py:34: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/vallox/__init__.py:133: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/vallox/__init__.py:138: error: Returning Any from function declared to return "str"  [no-any-return]
homeassistant/components/transmission/coordinator.py:161: error: Returning Any from function declared to return "bool | None"  [no-any-return]
homeassistant/components/workday/binary_sensor.py:107: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/wemo/entity.py:91: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/unifiprotect/utils.py:118: error: Returning Any from function declared to return "str"  [no-any-return]
homeassistant/components/unifiprotect/discovery.py:55: error: Returning Any from function declared to return "list[Any]"  [no-any-return]
homeassistant/components/unifi/entity.py:97: error: Free type variable expected in Generic[...]  [misc]
homeassistant/components/unifi/entity.py:114: error: "UnifiDescription" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/unifi/entity.py:118: error: Free type variable expected in Generic[...]  [misc]
homeassistant/components/unifi/entity.py:121: error: "UnifiEntityDescription" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/unifi/entity.py:128: error: "UnifiEntityDescription" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/zwave_js/update.py:259: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/zwave_js/discovery_data_template.py:574: error: Redundant cast to "Any | None"  [redundant-cast]
homeassistant/components/zwave_js/api.py:128: error: Parameter 1 of Literal[...] cannot be of type "Any"  [valid-type]
homeassistant/components/wemo/switch.py:100: error: Returning Any from function declared to return "str"  [no-any-return]
homeassistant/components/wemo/light.py:91: error: Returning Any from function declared to return "str"  [no-any-return]
homeassistant/components/wemo/light.py:101: error: Returning Any from function declared to return "str"  [no-any-return]
homeassistant/components/wemo/light.py:117: error: Returning Any from function declared to return "int"  [no-any-return]
homeassistant/components/wemo/light.py:122: error: Returning Any from function declared to return "tuple[float, float] | None"  [no-any-return]
homeassistant/components/wemo/light.py:127: error: Returning Any from function declared to return "int | None"  [no-any-return]
homeassistant/components/wemo/light.py:160: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/wemo/binary_sensor.py:47: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/velbus/switch.py:37: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/velbus/select.py:48: error: Returning Any from function declared to return "str"  [no-any-return]
homeassistant/components/velbus/light.py:59: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/velbus/light.py:116: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/velbus/cover.py:60: error: Returning Any from function declared to return "bool | None"  [no-any-return]
homeassistant/components/velbus/cover.py:65: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/velbus/cover.py:70: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/velbus/cover.py:81: error: Returning Any from function declared to return "int | None"  [no-any-return]
homeassistant/components/velbus/climate.py:49: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/velbus/climate.py:66: error: Returning Any from function declared to return "int | None"  [no-any-return]
homeassistant/components/velbus/binary_sensor.py:34: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/unifiprotect/data.py:77: error: Variable "homeassistant.components.unifiprotect.data.ProtectDeviceType" is not valid as a type  [valid-type]
homeassistant/components/unifiprotect/data.py:77: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
homeassistant/components/unifiprotect/data.py:230: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/unifiprotect/data.py:286: error: Variable "homeassistant.components.unifiprotect.data.ProtectDeviceType" is not valid as a type  [valid-type]
homeassistant/components/unifiprotect/data.py:286: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
homeassistant/components/unifiprotect/data.py:302: error: Variable "homeassistant.components.unifiprotect.data.ProtectDeviceType" is not valid as a type  [valid-type]
homeassistant/components/unifiprotect/data.py:302: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
homeassistant/components/unifiprotect/data.py:313: error: Variable "homeassistant.components.unifiprotect.data.ProtectDeviceType" is not valid as a type  [valid-type]
homeassistant/components/unifiprotect/data.py:313: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
homeassistant/components/unifiprotect/data.py:316: error: ProtectDeviceType? has no attribute "mac"  [attr-defined]
homeassistant/components/unifiprotect/data.py:319: error: ProtectDeviceType? has no attribute "name"  [attr-defined]
homeassistant/components/unifiprotect/data.py:319: error: ProtectDeviceType? has no attribute "mac"  [attr-defined]
homeassistant/components/unifiprotect/data.py:320: error: ProtectDeviceType? has no attribute "mac"  [attr-defined]
homeassistant/components/unifi/update.py:54: error: "UnifiEntityDescription" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/unifi/update.py:97: error: "UnifiEntity" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/unifi/switch.py:184: error: Free type variable expected in Generic[...]  [misc]
homeassistant/components/unifi/switch.py:194: error: "UnifiEntityDescription" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/unifi/switch.py:195: error: "UnifiSwitchEntityDescriptionMixin" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/unifi/switch.py:204: error: Type application has too many types (1 expected)  [misc]
homeassistant/components/unifi/switch.py:225: error: Type application has too many types (1 expected)  [misc]
homeassistant/components/unifi/switch.py:244: error: Type application has too many types (1 expected)  [misc]
homeassistant/components/unifi/switch.py:262: error: Type application has too many types (1 expected)  [misc]
homeassistant/components/unifi/switch.py:282: error: Type application has too many types (1 expected)  [misc]
homeassistant/components/unifi/switch.py:303: error: Type application has too many types (1 expected)  [misc]
homeassistant/components/unifi/switch.py:371: error: "UnifiEntity" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/unifi/switch.py:374: error: "UnifiSwitchEntityDescription" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/unifi/sensor.py:76: error: Returning Any from function declared to return "float"  [no-any-return]
homeassistant/components/unifi/sensor.py:77: error: Returning Any from function declared to return "float"  [no-any-return]
homeassistant/components/unifi/sensor.py:84: error: Returning Any from function declared to return "float"  [no-any-return]
homeassistant/components/unifi/sensor.py:85: error: Returning Any from function declared to return "float"  [no-any-return]
homeassistant/components/unifi/sensor.py:140: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/unifi/sensor.py:164: error: Free type variable expected in Generic[...]  [misc]
homeassistant/components/unifi/sensor.py:179: error: "UnifiEntityDescription" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/unifi/sensor.py:180: error: "UnifiSensorEntityDescriptionMixin" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/unifi/sensor.py:193: error: Type application has too many types (1 expected)  [misc]
homeassistant/components/unifi/sensor.py:215: error: Type application has too many types (1 expected)  [misc]
homeassistant/components/unifi/sensor.py:237: error: Type application has too many types (1 expected)  [misc]
homeassistant/components/unifi/sensor.py:257: error: Type application has too many types (1 expected)  [misc]
homeassistant/components/unifi/sensor.py:276: error: Type application has too many types (1 expected)  [misc]
homeassistant/components/unifi/sensor.py:294: error: Type application has too many types (1 expected)  [misc]
homeassistant/components/unifi/sensor.py:313: error: Type application has too many types (1 expected)  [misc]
homeassistant/components/unifi/sensor.py:333: error: Type application has too many types (1 expected)  [misc]
homeassistant/components/unifi/sensor.py:353: error: Type application has too many types (1 expected)  [misc]
homeassistant/components/unifi/sensor.py:372: error: Type application has too many types (1 expected)  [misc]
homeassistant/components/unifi/sensor.py:391: error: Type application has too many types (1 expected)  [misc]
homeassistant/components/unifi/sensor.py:424: error: "UnifiEntity" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/unifi/sensor.py:427: error: "UnifiSensorEntityDescription" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/unifi/image.py:36: error: Returning Any from function declared to return "bytes"  [no-any-return]
homeassistant/components/unifi/image.py:40: error: Free type variable expected in Generic[...]  [misc]
homeassistant/components/unifi/image.py:50: error: "UnifiEntityDescription" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/unifi/image.py:51: error: "UnifiImageEntityDescriptionMixin" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/unifi/image.py:57: error: Type application has too many types (1 expected)  [misc]
homeassistant/components/unifi/image.py:95: error: "UnifiEntity" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/unifi/image.py:98: error: "UnifiImageEntityDescription" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/unifi/image.py:108: error: "UnifiEntityDescription" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/unifi/device_tracker.py:141: error: Free type variable expected in Generic[...]  [misc]
homeassistant/components/unifi/device_tracker.py:152: error: "UnifiEntityDescription" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/unifi/device_tracker.py:153: error: "UnifiEntityTrackerDescriptionMixin" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/unifi/device_tracker.py:159: error: Type application has too many types (1 expected)  [misc]
homeassistant/components/unifi/device_tracker.py:183: error: Type application has too many types (1 expected)  [misc]
homeassistant/components/unifi/device_tracker.py:241: error: "UnifiEntity" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/unifi/button.py:61: error: Free type variable expected in Generic[...]  [misc]
homeassistant/components/unifi/button.py:70: error: "UnifiEntityDescription" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/unifi/button.py:71: error: "UnifiButtonEntityDescriptionMixin" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/unifi/button.py:77: error: Type application has too many types (1 expected)  [misc]
homeassistant/components/unifi/button.py:95: error: Type application has too many types (1 expected)  [misc]
homeassistant/components/unifi/button.py:132: error: "UnifiEntity" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/unifi/button.py:135: error: "UnifiButtonEntityDescription" expects 1 type argument, but 2 given  [type-arg]
homeassistant/components/tplink_omada/update.py:120: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/wled/switch.py:187: error: Returning Any from function declared to return "bool"  [no-any-return]
homeassistant/components/wled/select.py:94: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/wled/select.py:126: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/wled/select.py:170: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/wled/light.py:66: error: Returning Any from function declared to return "int | None"  [no-any-return]
homeassistant/components/wled/light.py:148: error: Returning Any from function declared to return "tuple[int, int, int] | None"  [no-any-return]
homeassistant/components/wled/light.py:161: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/wled/light.py:175: error: Returning Any from function declared to return "int | None"  [no-any-return]
homeassistant/components/unifiprotect/text.py:35: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/unifiprotect/text.py:36: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/unifiprotect/sensor.py:86: error: Returning Any from function declared to return "datetime | None"  [no-any-return]
homeassistant/components/unifiprotect/sensor.py:100: error: Returning Any from function declared to return "float | None"  [no-any-return]
homeassistant/components/unifiprotect/sensor.py:777: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/unifiprotect/select.py:139: error: Returning Any from function declared to return "str"  [no-any-return]
homeassistant/components/unifiprotect/select.py:145: error: Returning Any from function declared to return "str | None"  [no-any-return]
homeassistant/components/unifiprotect/lock.py:118: error: Returning Any from function declared to return "None"  [no-any-return]
homeassistant/components/unifiprotect/lock.py:123: error: Returning Any from function declared to return "None"  [no-any-return]
homeassistant/components/unifiprotect/camera.py:118: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/tts/__init__.py:900: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/tts/__init__.py:904: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/tts/__init__.py:908: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/zwave_js/sensor.py:335: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/zwave_js/sensor.py:499: error: Unused "type: ignore" comment  [unused-ignore]
homeassistant/components/zwave_js/sensor.py:675: error: Returning Any from function declared to return "str | int | float | None"  [no-any-return]
homeassistant/components/zwave_js/lock.py:137: error: Returning Any from function declared to return "bool | None"  [no-any-return]
homeassistant/components/zwave_js/cover.py:132: error: Returning Any from function declared to return "int"  [no-any-return]
homeassistant/components/zwave_js/cover.py:138: error: Returning Any from function declared to return "int"  [no-any-return]
homeassistant/components/zwave_js/cover.py:236: error: Returning Any from function declared to return "int"  [no-any-return]
homeassistant/components/zwave_js/cover.py:242: error: Returning Any from function declared to return "int"  [no-any-return]
homeassistant/components/zwave_js/cover.py:393: error: Returning Any from function declared to return "int"  [no-any-return]
homeassistant/components/zwave_js/cover.py:398: error: Returning Any from function declared to return "int"  [no-any-return]
homeassistant/components/zwave_js/cover.py:403: error: Returning Any from function declared to return "int"  [no-any-return]
homeassistant/components/zwave_js/climate.py:275: error: Returning Any from function declared to return "list[Any]"  [no-any-return]
homeassistant/components/withings/calendar.py:65: error: Returning Any from function declared to return "str"  [no-any-return]
Found 138 errors in 44 files (checked 1082 source files)

pylint...................................................................

r-xyz avatar Feb 28 '24 16:02 r-xyz

thanks @r-xyz, I couldn't reproduce it locally either, but it doesn't seem to occur in anyone else's CI workflows so it must be related to this branch. Interestingly I also get the google package error 🤷

malkstar avatar Feb 28 '24 20:02 malkstar

This is now broken in 2024.3.0b0

2024-02-28 23:12:18.660 ERROR (SyncWorker_7) [homeassistant.util.package] Unable to install package python-telegram-bot[socks]==20.8: ERROR: Cannot install python-telegram-bot because these package versions have conflicting dependencies.
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
2024-02-28 23:12:27.131 ERROR (SyncWorker_7) [homeassistant.util.package] Unable to install package python-telegram-bot[socks]==20.8: ERROR: Cannot install python-telegram-bot because these package versions have conflicting dependencies.
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
2024-02-28 23:12:35.095 ERROR (SyncWorker_7) [homeassistant.util.package] Unable to install package python-telegram-bot[socks]==20.8: ERROR: Cannot install python-telegram-bot because these package versions have conflicting dependencies.
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
2024-02-28 23:12:35.096 ERROR (MainThread) [homeassistant.setup] Setup failed for custom integration 'telegram_bot': Requirements for telegram_bot not found: ['python-telegram-bot[socks]==20.8'].```

luca-angemi avatar Feb 28 '24 22:02 luca-angemi

Hi all, Regarding the mypy error, I still do not fully understand the relation with the PR. According to file paths in the error (venv/lib/python3.11/site-packages/tenacity/[...]), the error affect tenacity package, not tornado. None of the files in the error, not the tenacity package are installed by any of the following: python-telegram-bot==13.1, python-telegram-bot[socks]=20.8, python-telegram-bot[socks,webhooks]=20.8. I tried to pip install them on clean virtual environment and checked under <venv>/lib/python/site-packages/....

Other point I noticed is that the CI job restores a previous virtual environment before running mypy; is that also coming from this same version of the code or it is cached from previous jobs (related to other commits)?

@luca-angemi , could you please share the version conflict in 2024.3.b.0? The relevant part (after "the conflict is caused by:") appear to be missing.

r-xyz avatar Feb 28 '24 23:02 r-xyz

@luca-angemi , could you please share the version conflict in 2024.3.b.0? The relevant part (after "the conflict is caused by:") appear to be missing.

@r-xyz That is all I have in the logs.

luca-angemi avatar Feb 28 '24 23:02 luca-angemi

Looks like the httpx upgrade got merged into home assistant yesterday, meaning we'll have to wait for the next python-telegram-bot release again unfortunately. It's been merged in the library too but no release yet.

malkstar avatar Feb 28 '24 23:02 malkstar

@r-xyz I went down this CI rabbit hole too, there is a pip issue that mentions tenacity being part of pip and requiring tornado which caused problems, but it was fixed in 21.1.3. I couldn't work out which pip version the CI uses.

malkstar avatar Feb 28 '24 23:02 malkstar

@malkstar , thanks for the insight. I was able to reproduce the error on Ubuntu 22.04 (used by CI) as well as on Debian 11 (used by ms image in devcontainers), as both shipped with pip <= 21.1.2 (fix implemented in 21.1.3)

virtualenv test
source test/bin/activate
mypy test//lib/python3.11/site-packages/tenacity

Resulted in same error as above.

Not sure if tenacity is required by pip or any other library, but it is now confirmed that mypy failure is a bug of the rest of core codebase, not of the telegram_bot component nor its dependencies. Previous python-telegram-bot==11.3 required to install tornado and made the bug to go unnoticed until now since it was installing a dependency required by another library but not listed in requirements due to the above bug.

I suggest to track down which integration/dependency is installing tenacity and fix the bug accordingly (either upgrading pip or re-adding tornado dependency temporarily, but linked to the correct piece of codebase requiring tenacity).

r-xyz avatar Feb 29 '24 00:02 r-xyz

The integration requiring tenacity happen to be kef.

EDIT: kef is the only one showing it in requirements. Other root dependencies identified with pipdeptree are:

  • linear-garage-door
  • nibe
  • py-aosmith
  • pyenphase
  • pytrydan
  • smart-meter-texas
  • yolink-api

r-xyz avatar Feb 29 '24 00:02 r-xyz

There are multiple integrations that require tenacity. This is already known. I've been trying to reproduce the issue so I can confirm that my fix works. I'll try to downgrade pip to the mentioned version, thanks for that lead.

MartinHjelmare avatar Feb 29 '24 00:02 MartinHjelmare

I got confused with pip version numbers and did not notice a downgrade - not update - might be required.

  • 21.1.3 implemented the fix.
  • 22.0.2 on Ubuntu 22.04
  • 23.1.2 on devcontainer image

Not sure if depends on pip version, then, but for sure it can be avoided by adding requirements for the above integrations (I updated the list).

r-xyz avatar Feb 29 '24 01:02 r-xyz

@malkstar so because of the httpx upgrade now this cannot be run not even as a custom component, right?

luca-angemi avatar Feb 29 '24 06:02 luca-angemi

Hi again, Not sure how mypy loads the ignores, but it seem it is not respecting the tornado.* ones defined in tenacity pyproject.toml. Could we just add this ignore to mypy settings?

r-xyz avatar Mar 04 '24 20:03 r-xyz

The pinning strategy of httpx in python-telegram-bot will unfortunately make our requirements handling very fragile. I don't think we can accept this bump until either they have loosened that pinning or we change to a different requirements handler than pip that allows overriding specific requirements. We're looking at eg astral-sh/uv for that.

MartinHjelmare avatar Mar 05 '24 14:03 MartinHjelmare

Not sure if there is any chance to get dependencies loosened from python-telegram-bot, but since they mention on the Readme to get in touch, I have tried to politely ask the devs here

r-xyz avatar Mar 05 '24 15:03 r-xyz

https://github.com/python-telegram-bot/python-telegram-bot/pull/4148 Work in progress... Hopefully it might be merged into 21.0 :crossed_fingers:

r-xyz avatar Mar 05 '24 18:03 r-xyz