From 1ede84774477776b488d9c7745f87e0e85b4ec5d Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 26 Sep 2023 11:57:42 +0200 Subject: [PATCH 01/20] Add classifer for 3.12 --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 9b8642172ce8c..0710e7fcec7b5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,6 +19,7 @@ classifiers = [ "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Home Automation", ] requires-python = ">=3.11.0" From 1e0680a0cbc14246eed147c5a52a75acad0e8508 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sun, 8 Oct 2023 13:50:25 +0200 Subject: [PATCH 02/20] Update workflows --- .github/workflows/ci.yaml | 2 +- .github/workflows/wheels.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4a7ad03f21834..ba4a37fda1404 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -39,7 +39,7 @@ env: BLACK_CACHE_VERSION: 1 HA_SHORT_VERSION: "2023.11" DEFAULT_PYTHON: "3.11" - ALL_PYTHON_VERSIONS: "['3.11']" + ALL_PYTHON_VERSIONS: "['3.11', '3.12']" # 10.3 is the oldest supported version # - 10.3.32 is the version currently shipped with Synology (as of 17 Feb 2022) # 10.6 is the current long-term-support diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 83f81b0cd4a45..f3bab1872c7b6 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -82,7 +82,7 @@ jobs: strategy: fail-fast: false matrix: - abi: ["cp311"] + abi: ["cp311", "cp312"] arch: ${{ fromJson(needs.init.outputs.architectures) }} steps: - name: Checkout the repository @@ -112,7 +112,7 @@ jobs: requirements-diff: "requirements_diff.txt" requirements: "requirements.txt" - integrations_cp311: + integrations: name: Build wheels ${{ matrix.abi }} for ${{ matrix.arch }} if: github.repository_owner == 'home-assistant' needs: init @@ -120,7 +120,7 @@ jobs: strategy: fail-fast: false matrix: - abi: ["cp311"] + abi: ["cp311", "cp312"] arch: ${{ fromJson(needs.init.outputs.architectures) }} steps: - name: Checkout the repository From fcda1970667346a691af8f7695da74676f5d189b Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sun, 8 Oct 2023 13:42:42 +0200 Subject: [PATCH 03/20] Disable RestrictedPython --- homeassistant/components/python_script/manifest.json | 1 + requirements_all.txt | 3 --- requirements_test_all.txt | 3 --- tests/components/python_script/conftest.py | 3 +++ 4 files changed, 4 insertions(+), 6 deletions(-) create mode 100644 tests/components/python_script/conftest.py diff --git a/homeassistant/components/python_script/manifest.json b/homeassistant/components/python_script/manifest.json index 80ed6164e74b0..25da3c550e517 100644 --- a/homeassistant/components/python_script/manifest.json +++ b/homeassistant/components/python_script/manifest.json @@ -2,6 +2,7 @@ "domain": "python_script", "name": "Python Scripts", "codeowners": [], + "disabled": "Dependencies does not support Python 3.12", "documentation": "https://www.home-assistant.io/integrations/python_script", "loggers": ["RestrictedPython"], "quality_scale": "internal", diff --git a/requirements_all.txt b/requirements_all.txt index e5eeaaa48f650..0948735e7ebd5 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -121,9 +121,6 @@ PyXiaomiGateway==0.14.3 # homeassistant.components.rachio RachioPy==1.0.3 -# homeassistant.components.python_script -RestrictedPython==6.2 - # homeassistant.components.remember_the_milk RtmAPI==0.7.2 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 6f08b72228df9..b350fa2e41e23 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -108,9 +108,6 @@ PyXiaomiGateway==0.14.3 # homeassistant.components.rachio RachioPy==1.0.3 -# homeassistant.components.python_script -RestrictedPython==6.2 - # homeassistant.components.remember_the_milk RtmAPI==0.7.2 diff --git a/tests/components/python_script/conftest.py b/tests/components/python_script/conftest.py new file mode 100644 index 0000000000000..b93cb082fd266 --- /dev/null +++ b/tests/components/python_script/conftest.py @@ -0,0 +1,3 @@ +"""Skip test collection.""" + +collect_ignore_glob = ["test_*.py"] From adcb7cbb025f45d8353849ae2f7af8f1c0426078 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 18 Jul 2023 04:15:12 +0200 Subject: [PATCH 04/20] Disable guppy3 --- homeassistant/components/profiler/manifest.json | 1 + requirements_all.txt | 9 --------- requirements_test_all.txt | 9 --------- tests/components/profiler/conftest.py | 3 +++ 4 files changed, 4 insertions(+), 18 deletions(-) create mode 100644 tests/components/profiler/conftest.py diff --git a/homeassistant/components/profiler/manifest.json b/homeassistant/components/profiler/manifest.json index 1b33c77884380..3939b71994b20 100644 --- a/homeassistant/components/profiler/manifest.json +++ b/homeassistant/components/profiler/manifest.json @@ -3,6 +3,7 @@ "name": "Profiler", "codeowners": ["@bdraco"], "config_flow": true, + "disabled": "Dependencies does not support Python 3.12", "documentation": "https://www.home-assistant.io/integrations/profiler", "quality_scale": "internal", "requirements": ["pyprof2calltree==1.4.5", "guppy3==3.1.3", "objgraph==3.5.0"] diff --git a/requirements_all.txt b/requirements_all.txt index 0948735e7ebd5..fe70ae06a3461 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -935,9 +935,6 @@ gspread==5.5.0 # homeassistant.components.gstreamer gstreamer-player==1.1.2 -# homeassistant.components.profiler -guppy3==3.1.3 - # homeassistant.components.iaqualink h2==4.1.0 @@ -1325,9 +1322,6 @@ oasatelematics==0.3 # homeassistant.components.google oauth2client==4.1.3 -# homeassistant.components.profiler -objgraph==3.5.0 - # homeassistant.components.garages_amsterdam odp-amsterdam==5.3.1 @@ -1945,9 +1939,6 @@ pyplaato==0.0.18 # homeassistant.components.point pypoint==2.3.2 -# homeassistant.components.profiler -pyprof2calltree==1.4.5 - # homeassistant.components.prosegur pyprosegur==0.0.9 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index b350fa2e41e23..a6e0b4ea1dd14 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -736,9 +736,6 @@ growattServer==1.3.0 # homeassistant.components.google_sheets gspread==5.5.0 -# homeassistant.components.profiler -guppy3==3.1.3 - # homeassistant.components.iaqualink h2==4.1.0 @@ -1027,9 +1024,6 @@ numpy==1.26.0 # homeassistant.components.google oauth2client==4.1.3 -# homeassistant.components.profiler -objgraph==3.5.0 - # homeassistant.components.garages_amsterdam odp-amsterdam==5.3.1 @@ -1467,9 +1461,6 @@ pyplaato==0.0.18 # homeassistant.components.point pypoint==2.3.2 -# homeassistant.components.profiler -pyprof2calltree==1.4.5 - # homeassistant.components.prosegur pyprosegur==0.0.9 diff --git a/tests/components/profiler/conftest.py b/tests/components/profiler/conftest.py new file mode 100644 index 0000000000000..b93cb082fd266 --- /dev/null +++ b/tests/components/profiler/conftest.py @@ -0,0 +1,3 @@ +"""Skip test collection.""" + +collect_ignore_glob = ["test_*.py"] From 7b8b1c14fedf632e226a22e8613cba1efa4b3117 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 18 Jul 2023 02:39:49 +0200 Subject: [PATCH 05/20] Disable datapoint --- homeassistant/components/metoffice/manifest.json | 1 + requirements_all.txt | 3 --- requirements_test_all.txt | 3 --- tests/components/metoffice/conftest.py | 5 ++++- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/metoffice/manifest.json b/homeassistant/components/metoffice/manifest.json index cfe6e6de9cd4d..b16a68378aa7a 100644 --- a/homeassistant/components/metoffice/manifest.json +++ b/homeassistant/components/metoffice/manifest.json @@ -3,6 +3,7 @@ "name": "Met Office", "codeowners": ["@MrHarcombe", "@avee87"], "config_flow": true, + "disabled": "Dependencies does not support Python 3.12", "documentation": "https://www.home-assistant.io/integrations/metoffice", "iot_class": "cloud_polling", "loggers": ["datapoint"], diff --git a/requirements_all.txt b/requirements_all.txt index fe70ae06a3461..efe03e4aa35fd 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -638,9 +638,6 @@ crownstone-uart==2.1.0 # homeassistant.components.datadog datadog==0.15.0 -# homeassistant.components.metoffice -datapoint==0.9.8 - # homeassistant.components.bluetooth dbus-fast==2.11.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index a6e0b4ea1dd14..59b31378894f0 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -521,9 +521,6 @@ crownstone-uart==2.1.0 # homeassistant.components.datadog datadog==0.15.0 -# homeassistant.components.metoffice -datapoint==0.9.8 - # homeassistant.components.bluetooth dbus-fast==2.11.1 diff --git a/tests/components/metoffice/conftest.py b/tests/components/metoffice/conftest.py index b1d1c9f508e27..0b82ac3fb7fab 100644 --- a/tests/components/metoffice/conftest.py +++ b/tests/components/metoffice/conftest.py @@ -1,9 +1,12 @@ """Fixtures for Met Office weather integration tests.""" +# ruff: noqa: F821 from unittest.mock import patch -from datapoint.exceptions import APIException +# from datapoint.exceptions import APIException import pytest +collect_ignore_glob = ["test_*.py"] + @pytest.fixture def mock_simple_manager_fail(): From 53c650c46650573cc8d1549841ebd167ab3e5d3b Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 18 Jul 2023 03:07:48 +0200 Subject: [PATCH 06/20] Disable webexteamssdk --- homeassistant/components/cisco_webex_teams/manifest.json | 1 + requirements_all.txt | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/homeassistant/components/cisco_webex_teams/manifest.json b/homeassistant/components/cisco_webex_teams/manifest.json index 4fe333f40a5b7..3d3d5e5774190 100644 --- a/homeassistant/components/cisco_webex_teams/manifest.json +++ b/homeassistant/components/cisco_webex_teams/manifest.json @@ -2,6 +2,7 @@ "domain": "cisco_webex_teams", "name": "Cisco Webex Teams", "codeowners": ["@fbradyirl"], + "disabled": "Dependencies does not support Python 3.12", "documentation": "https://www.home-assistant.io/integrations/cisco_webex_teams", "iot_class": "cloud_push", "loggers": ["webexteamssdk"], diff --git a/requirements_all.txt b/requirements_all.txt index efe03e4aa35fd..073b9bec1b942 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2681,9 +2681,6 @@ watchdog==2.3.1 # homeassistant.components.waterfurnace waterfurnace==1.1.0 -# homeassistant.components.cisco_webex_teams -webexteamssdk==1.1.1 - # homeassistant.components.assist_pipeline webrtc-noise-gain==1.2.3 From b53003e588993fcaf6b7632164fbc7ccc9edd364 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Fri, 21 Jul 2023 00:02:59 +0200 Subject: [PATCH 07/20] Disable aiokafka --- homeassistant/components/apache_kafka/manifest.json | 1 + requirements_all.txt | 3 --- requirements_test_all.txt | 3 --- tests/components/apache_kafka/conftest.py | 3 +++ 4 files changed, 4 insertions(+), 6 deletions(-) create mode 100644 tests/components/apache_kafka/conftest.py diff --git a/homeassistant/components/apache_kafka/manifest.json b/homeassistant/components/apache_kafka/manifest.json index 11cb0ece7acc3..9a20a5750904b 100644 --- a/homeassistant/components/apache_kafka/manifest.json +++ b/homeassistant/components/apache_kafka/manifest.json @@ -2,6 +2,7 @@ "domain": "apache_kafka", "name": "Apache Kafka", "codeowners": ["@bachya"], + "disabled": "Dependencies does not support Python 3.12", "documentation": "https://www.home-assistant.io/integrations/apache_kafka", "iot_class": "local_push", "loggers": ["aiokafka", "kafka_python"], diff --git a/requirements_all.txt b/requirements_all.txt index 073b9bec1b942..ba85a06919b76 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -258,9 +258,6 @@ aiohue==4.7.0 # homeassistant.components.imap aioimaplib==1.0.1 -# homeassistant.components.apache_kafka -aiokafka==0.7.2 - # homeassistant.components.kef aiokef==0.2.16 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 59b31378894f0..de0c945faebd5 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -236,9 +236,6 @@ aiohue==4.7.0 # homeassistant.components.imap aioimaplib==1.0.1 -# homeassistant.components.apache_kafka -aiokafka==0.7.2 - # homeassistant.components.lifx aiolifx-effects==0.3.2 diff --git a/tests/components/apache_kafka/conftest.py b/tests/components/apache_kafka/conftest.py new file mode 100644 index 0000000000000..b93cb082fd266 --- /dev/null +++ b/tests/components/apache_kafka/conftest.py @@ -0,0 +1,3 @@ +"""Skip test collection.""" + +collect_ignore_glob = ["test_*.py"] From bab5deee82845d12417d366a24f6b87671989ded Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Fri, 21 Jul 2023 00:03:57 +0200 Subject: [PATCH 08/20] Disable vulcan-api --- homeassistant/components/vulcan/manifest.json | 1 + requirements_all.txt | 3 --- requirements_test_all.txt | 3 --- tests/components/vulcan/conftest.py | 3 +++ 4 files changed, 4 insertions(+), 6 deletions(-) create mode 100644 tests/components/vulcan/conftest.py diff --git a/homeassistant/components/vulcan/manifest.json b/homeassistant/components/vulcan/manifest.json index fea87480cf0de..d732310e1349f 100644 --- a/homeassistant/components/vulcan/manifest.json +++ b/homeassistant/components/vulcan/manifest.json @@ -3,6 +3,7 @@ "name": "Uonet+ Vulcan", "codeowners": ["@Antoni-Czaplicki"], "config_flow": true, + "disabled": "Dependencies does not support Python 3.12", "documentation": "https://www.home-assistant.io/integrations/vulcan", "iot_class": "cloud_polling", "quality_scale": "silver", diff --git a/requirements_all.txt b/requirements_all.txt index ba85a06919b76..4c14149aa6b33 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2659,9 +2659,6 @@ vsure==2.6.6 # homeassistant.components.vasttrafik vtjp==0.1.14 -# homeassistant.components.vulcan -vulcan-api==2.3.0 - # homeassistant.components.vultr vultr==0.1.2 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index de0c945faebd5..dd18194875160 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1971,9 +1971,6 @@ volvooncall==0.10.3 # homeassistant.components.verisure vsure==2.6.6 -# homeassistant.components.vulcan -vulcan-api==2.3.0 - # homeassistant.components.vultr vultr==0.1.2 diff --git a/tests/components/vulcan/conftest.py b/tests/components/vulcan/conftest.py new file mode 100644 index 0000000000000..9b8920595be96 --- /dev/null +++ b/tests/components/vulcan/conftest.py @@ -0,0 +1,3 @@ +"""Skip test collection for Python 3.12.""" + +collect_ignore_glob = ["test_*.py"] From 633ea53806e6b74df52ba2fb8ff722776ff7551d Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Fri, 21 Jul 2023 14:25:00 +0200 Subject: [PATCH 09/20] Disable pysnmplib --- homeassistant/components/brother/manifest.json | 1 + homeassistant/components/snmp/manifest.json | 1 + requirements_all.txt | 6 ------ requirements_test_all.txt | 6 ------ tests/components/brother/__init__.py | 3 ++- tests/components/brother/conftest.py | 2 ++ tests/components/snmp/conftest.py | 3 +++ 7 files changed, 9 insertions(+), 13 deletions(-) create mode 100644 tests/components/snmp/conftest.py diff --git a/homeassistant/components/brother/manifest.json b/homeassistant/components/brother/manifest.json index cba44b68c6ac4..7a40fb63bc7a1 100644 --- a/homeassistant/components/brother/manifest.json +++ b/homeassistant/components/brother/manifest.json @@ -3,6 +3,7 @@ "name": "Brother Printer", "codeowners": ["@bieniu"], "config_flow": true, + "disabled": "Dependencies does not support Python 3.12", "documentation": "https://www.home-assistant.io/integrations/brother", "integration_type": "device", "iot_class": "local_polling", diff --git a/homeassistant/components/snmp/manifest.json b/homeassistant/components/snmp/manifest.json index 324a1e493661c..cb9fd4702ad02 100644 --- a/homeassistant/components/snmp/manifest.json +++ b/homeassistant/components/snmp/manifest.json @@ -2,6 +2,7 @@ "domain": "snmp", "name": "SNMP", "codeowners": [], + "disabled": "Dependencies does not support Python 3.12", "documentation": "https://www.home-assistant.io/integrations/snmp", "iot_class": "local_polling", "loggers": ["pyasn1", "pysmi", "pysnmp"], diff --git a/requirements_all.txt b/requirements_all.txt index 4c14149aa6b33..5657b1f4cc6a4 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -562,9 +562,6 @@ boto3==1.28.17 # homeassistant.components.broadlink broadlink==0.18.3 -# homeassistant.components.brother -brother==2.3.0 - # homeassistant.components.brottsplatskartan brottsplatskartan==0.0.1 @@ -2025,9 +2022,6 @@ pysmartthings==0.7.8 # homeassistant.components.edl21 pysml==0.0.12 -# homeassistant.components.snmp -pysnmplib==5.0.21 - # homeassistant.components.snooz pysnooz==0.8.6 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index dd18194875160..fc7ad4eeb5576 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -472,9 +472,6 @@ boschshcpy==0.2.57 # homeassistant.components.broadlink broadlink==0.18.3 -# homeassistant.components.brother -brother==2.3.0 - # homeassistant.components.brottsplatskartan brottsplatskartan==0.0.1 @@ -1526,9 +1523,6 @@ pysmartthings==0.7.8 # homeassistant.components.edl21 pysml==0.0.12 -# homeassistant.components.snmp -pysnmplib==5.0.21 - # homeassistant.components.snooz pysnooz==0.8.6 diff --git a/tests/components/brother/__init__.py b/tests/components/brother/__init__.py index 8e24c2d8058f5..8dd27ffc88710 100644 --- a/tests/components/brother/__init__.py +++ b/tests/components/brother/__init__.py @@ -1,8 +1,9 @@ """Tests for Brother Printer integration.""" +# ruff: noqa: F821 import json from unittest.mock import patch -from homeassistant.components.brother.const import DOMAIN +# from homeassistant.components.brother.const import DOMAIN from homeassistant.const import CONF_HOST, CONF_TYPE from homeassistant.core import HomeAssistant diff --git a/tests/components/brother/conftest.py b/tests/components/brother/conftest.py index 9e81cce9d123c..a667b37c59f3a 100644 --- a/tests/components/brother/conftest.py +++ b/tests/components/brother/conftest.py @@ -4,6 +4,8 @@ import pytest +collect_ignore_glob = ["test_*.py"] + @pytest.fixture def mock_setup_entry() -> Generator[AsyncMock, None, None]: diff --git a/tests/components/snmp/conftest.py b/tests/components/snmp/conftest.py new file mode 100644 index 0000000000000..9b8920595be96 --- /dev/null +++ b/tests/components/snmp/conftest.py @@ -0,0 +1,3 @@ +"""Skip test collection for Python 3.12.""" + +collect_ignore_glob = ["test_*.py"] From bb2556da15a3802c9891cc8b86c42098c572971e Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sun, 8 Oct 2023 13:47:38 +0200 Subject: [PATCH 10/20] Filter more pytest warnings --- pyproject.toml | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 0710e7fcec7b5..500b08dd72d24 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -440,6 +440,8 @@ filterwarnings = [ "ignore:ssl.TLSVersion.TLSv1 is deprecated:DeprecationWarning:elkm1_lib.util", # https://github.com/michaeldavie/env_canada/blob/v0.5.37/env_canada/ec_cache.py "ignore:Inheritance class CacheClientSession from ClientSession is discouraged:DeprecationWarning:env_canada.ec_cache", + # https://github.com/allenporter/ical/pull/215 - v5.0.0 + "ignore:datetime.*utcnow\\(\\) is deprecated and scheduled for removal:DeprecationWarning:ical.util", # https://github.com/bachya/regenmaschine/blob/2023.08.0/regenmaschine/client.py#L51 "ignore:ssl.TLSVersion.SSLv3 is deprecated:DeprecationWarning:regenmaschine.client", @@ -452,6 +454,13 @@ filterwarnings = [ # -- tracked upstream / open PRs # https://github.com/caronc/apprise/issues/659 - v1.4.5 "ignore:Use setlocale\\(\\), getencoding\\(\\) and getlocale\\(\\) instead:DeprecationWarning:apprise.AppriseLocal", + # https://github.com/kiorky/croniter/issues/49 - v1.4.1 + "ignore:datetime.*utcfromtimestamp\\(\\) is deprecated and scheduled for removal:DeprecationWarning:croniter.croniter", + # https://github.com/spulec/freezegun/issues/508 - v1.2.2 + # https://github.com/spulec/freezegun/pull/511 + "ignore:datetime.*utcnow\\(\\) is deprecated and scheduled for removal:DeprecationWarning:freezegun.api", + # https://github.com/influxdata/influxdb-client-python/issues/603 - v1.37.0 + "ignore:datetime.*utcfromtimestamp\\(\\) is deprecated and scheduled for removal:DeprecationWarning:influxdb_client.client.write.point", # https://github.com/beetbox/mediafile/issues/67 - v0.12.0 "ignore:'imghdr' is deprecated and slated for removal in Python 3.13:DeprecationWarning:mediafile", # https://github.com/eclipse/paho.mqtt.python/issues/653 - v1.6.1 @@ -459,6 +468,8 @@ filterwarnings = [ "ignore:ssl.PROTOCOL_TLS is deprecated:DeprecationWarning:paho.mqtt.client", # https://github.com/PythonCharmers/python-future/issues/488 - v0.18.3 "ignore:the imp module is deprecated in favour of importlib and slated for removal in Python 3.12:DeprecationWarning:future.standard_library", + # https://github.com/frenck/python-toonapi/pull/9 - v0.2.1 - 2021-09-23 + "ignore:datetime.*utcnow\\(\\) is deprecated and scheduled for removal:DeprecationWarning:toonapi.models", # https://github.com/foxel/python_ndms2_client/issues/6 - v0.1.2 "ignore:'telnetlib' is deprecated and slated for removal in Python 3.13:DeprecationWarning:ndms2_client.connection", # https://github.com/pytest-dev/pytest-cov/issues/557 - v4.1.0 @@ -466,14 +477,40 @@ filterwarnings = [ "ignore:The --rsyncdir command line argument and rsyncdirs config variable are deprecated:DeprecationWarning:xdist.plugin", # -- fixed, waiting for release / update + # https://github.com/ludeeus/aiogithubapi/pull/208 - >=23.9.0 + "ignore:datetime.*utcnow\\(\\) is deprecated and scheduled for removal:DeprecationWarning:aiogithubapi.namespaces.events", + # https://github.com/bachya/aiopurpleair/pull/200 - >2023.08.0 + "ignore:datetime.*utcfromtimestamp\\(\\) is deprecated and scheduled for removal:DeprecationWarning:aiopurpleair.helpers.validators", + # https://github.com/scrapinghub/dateparser/pull/1179 - >1.1.8 + "ignore:datetime.*utcnow\\(\\) is deprecated and scheduled for removal:DeprecationWarning:dateparser.timezone_parser", + # https://github.com/zopefoundation/DateTime/pull/55 - >5.2 + "ignore:datetime.*utcfromtimestamp\\(\\) is deprecated and scheduled for removal:DeprecationWarning:DateTime.pytz_support", # https://github.com/kurtmckee/feedparser/issues/330 - >6.0.10 "ignore:'cgi' is deprecated and slated for removal in Python 3.13:DeprecationWarning:feedparser.encodings", # https://github.com/jaraco/jaraco.abode/commit/9e3e789efc96cddcaa15f920686bbeb79a7469e0 - update jaraco.abode to >=5.1.0 "ignore:`jaraco.functools.call_aside` is deprecated, use `jaraco.functools.invoke` instead:DeprecationWarning:jaraco.abode.helpers.timeline", # https://github.com/nextcord/nextcord/pull/1095 - >2.6.1 "ignore:pkg_resources is deprecated as an API:DeprecationWarning:nextcord.health_check", + # https://github.com/pytest-dev/pytest/pull/10894 - >=7.4.0 + "ignore:ast.(Str|Num|NameConstant) is deprecated and will be removed in Python 3.14:DeprecationWarning:_pytest.assertion.rewrite", + "ignore:Attribute s is deprecated and will be removed in Python 3.14:DeprecationWarning:_pytest.assertion.rewrite", + # https://github.com/bachya/pytile/pull/280 - >2023.08.0 + "ignore:datetime.*utcfromtimestamp\\(\\) is deprecated and scheduled for removal:DeprecationWarning:pytile.tile", + # https://github.com/rytilahti/python-miio/pull/1809 - >0.5.12 + "ignore:datetime.*utcnow\\(\\) is deprecated and scheduled for removal:DeprecationWarning:miio.protocol", + "ignore:datetime.*utcnow\\(\\) is deprecated and scheduled for removal:DeprecationWarning:miio.miioprotocol", + # https://github.com/hunterjm/python-onvif-zeep-async/pull/51 - >3.1.12 + "ignore:datetime.*utcnow\\(\\) is deprecated and scheduled for removal:DeprecationWarning:onvif.client", + # Fixed upstream in python-telegram-bot - >=20.0 + "ignore:python-telegram-bot is using upstream urllib3:UserWarning:telegram.utils.request", + # https://github.com/ludeeus/pytraccar/pull/15 - >1.0.0 + "ignore:datetime.*utcnow\\(\\) is deprecated and scheduled for removal:DeprecationWarning:pytraccar.client", + # https://github.com/zopefoundation/RestrictedPython/pull/259 - >=7.0a1.dev0 + "ignore:ast\\.(Str|Num) is deprecated and will be removed in Python 3.14:DeprecationWarning:RestrictedPython.transformer", # https://github.com/grahamwetzler/smart-meter-texas/pull/143 - >0.5.3 "ignore:ssl.OP_NO_SSL\\*/ssl.OP_NO_TLS\\* options are deprecated:DeprecationWarning:smart_meter_texas", + # https://github.com/Bluetooth-Devices/xiaomi-ble/pull/59 - >0.21.1 + "ignore:datetime.*utcfromtimestamp\\(\\) is deprecated and scheduled for removal:DeprecationWarning:xiaomi_ble.parser", # -- not helpful # pyatmo.__init__ imports deprecated moduls from itself - v7.5.0 @@ -488,6 +525,17 @@ filterwarnings = [ "ignore:It looks like you're parsing an XML document using an HTML parser:UserWarning:bs4.builder", # New in aiohttp - v3.9.0 "ignore:It is recommended to use web.AppKey instances for keys:UserWarning:(homeassistant|tests|aiohttp_cors)", + # https://github.com/protocolbuffers/protobuf - v4.24.3 + "ignore:datetime.*utcfromtimestamp\\(\\) is deprecated and scheduled for removal:DeprecationWarning:google.protobuf.internal.well_known_types", + "ignore:Type google._upb._message.(Message|Scalar)MapContainer uses PyType_Spec with a metaclass that has custom tp_new. .* Python 3.14:DeprecationWarning", + # https://github.com/googleapis/google-auth-library-python/blob/v2.23.2/google/auth/_helpers.py#L95 - v2.23.2 + "ignore:datetime.*utcnow\\(\\) is deprecated:DeprecationWarning:google.auth._helpers", + # https://github.com/googleapis/proto-plus-python/blob/v1.22.3/proto/datetime_helpers.py#L24 - v1.22.3 + "ignore:datetime.*utcfromtimestamp\\(\\) is deprecated:DeprecationWarning:proto.datetime_helpers", + # https://github.com/MatsNl/pyatag/issues/11 -> no recent activity - v0.3.6.2 + "ignore:datetime.*utcnow\\(\\) is deprecated and scheduled for removal:DeprecationWarning:pyatag.gateway", + # https://github.com/Python-MyQ/Python-MyQ -> fork - v3.1.11 + "ignore:datetime.*utcnow\\(\\) is deprecated and scheduled for removal:DeprecationWarning:pymyq.(api|account)", # -- unmaintained projects, last release about 2+ years # https://pypi.org/project/agent-py/ - v0.0.23 - 2020-06-04 @@ -496,10 +544,13 @@ filterwarnings = [ "ignore:with timeout\\(\\) is deprecated:DeprecationWarning:aiomodernforms.modernforms", # https://pypi.org/project/directv/ - v0.4.0 - 2020-09-12 "ignore:with timeout\\(\\) is deprecated:DeprecationWarning:directv.directv", + "ignore:datetime.*utcnow\\(\\) is deprecated and scheduled for removal:DeprecationWarning:directv.models", # https://pypi.org/project/emulated-roku/ - v0.2.1 - 2020-01-23 (archived) "ignore:loop argument is deprecated:DeprecationWarning:emulated_roku", # https://pypi.org/project/foobot_async/ - v1.0.0 - 2020-11-24 "ignore:with timeout\\(\\) is deprecated:DeprecationWarning:foobot_async", + # https://pypi.org/project/influxdb/ - v5.3.1 - 2020-11-11 (archived) + "ignore:datetime.*utcfromtimestamp\\(\\) is deprecated and scheduled for removal:DeprecationWarning:influxdb.line_protocol", # https://pypi.org/project/lark-parser/ - v0.12.0 - 2021-08-30 -> moved to `lark` # https://pypi.org/project/commentjson/ - v0.9.0 - 2020-10-05 # https://github.com/vaidik/commentjson/issues/51 @@ -508,11 +559,17 @@ filterwarnings = [ "ignore:module '(sre_parse|sre_constants)' is deprecate:DeprecationWarning:lark.utils", # https://pypi.org/project/lomond/ - v0.3.3 - 2018-09-21 "ignore:ssl.PROTOCOL_TLS is deprecated:DeprecationWarning:lomond.session", + # https://pypi.org/project/oauth2client/ - v4.1.3 - 2018-09-07 (archived) + "ignore:datetime.*utcnow\\(\\) is deprecated and scheduled for removal:DeprecationWarning:oauth2client.client", # https://pypi.org/project/passlib/ - v1.7.4 - 2020-10-08 "ignore:'crypt' is deprecated and slated for removal in Python 3.13:DeprecationWarning:passlib.utils", + # https://pypi.org/project/PyMetEireann/ - v2021.8.0 - 2021-08-16 + "ignore:datetime.*utcnow\\(\\) is deprecated and scheduled for removal:DeprecationWarning:meteireann", # https://pypi.org/project/pyqwikswitch/ - v0.94 - 2019-08-19 "ignore:client.loop property is deprecated:DeprecationWarning:pyqwikswitch.async_", "ignore:with timeout\\(\\) is deprecated:DeprecationWarning:pyqwikswitch.async_", + # https://pypi.org/project/Rx/ - v3.2.0 - 2021-04-25 + "ignore:datetime.*utcfromtimestamp\\(\\) is deprecated and scheduled for removal:DeprecationWarning:rx.internal.constants", # https://pypi.org/project/rxv/ - v0.7.0 - 2021-10-10 "ignore:defusedxml.cElementTree is deprecated, import from defusedxml.ElementTree instead:DeprecationWarning:rxv.ssdp", # https://pypi.org/project/vilfo-api-client/ - v0.4.1 - 2021-11-06 From e9d8b5ee7830c615256326d94c36a26d0c23cef3 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 10 Oct 2023 01:25:30 +0200 Subject: [PATCH 11/20] Modify profiler --- homeassistant/components/profiler/__init__.py | 5 +++++ .../components/profiler/manifest.json | 7 ++++-- requirements_all.txt | 9 ++++++++ requirements_test_all.txt | 9 ++++++++ tests/components/profiler/conftest.py | 3 --- tests/components/profiler/test_init.py | 22 +++++++++++++++++++ 6 files changed, 50 insertions(+), 5 deletions(-) delete mode 100644 tests/components/profiler/conftest.py diff --git a/homeassistant/components/profiler/__init__.py b/homeassistant/components/profiler/__init__.py index 8c5c206ae9ff3..8b0252e7fa760 100644 --- a/homeassistant/components/profiler/__init__.py +++ b/homeassistant/components/profiler/__init__.py @@ -402,6 +402,11 @@ async def _async_generate_memory_profile(hass: HomeAssistant, call: ServiceCall) # Imports deferred to avoid loading modules # in memory since usually only one part of this # integration is used at a time + if sys.version_info >= (3, 12): + raise HomeAssistantError( + "Memory profiling is not supported on Python 3.12. Please use Python 3.11." + ) + from guppy import hpy # pylint: disable=import-outside-toplevel start_time = int(time.time() * 1000000) diff --git a/homeassistant/components/profiler/manifest.json b/homeassistant/components/profiler/manifest.json index 3939b71994b20..eeb0a182ee38c 100644 --- a/homeassistant/components/profiler/manifest.json +++ b/homeassistant/components/profiler/manifest.json @@ -3,8 +3,11 @@ "name": "Profiler", "codeowners": ["@bdraco"], "config_flow": true, - "disabled": "Dependencies does not support Python 3.12", "documentation": "https://www.home-assistant.io/integrations/profiler", "quality_scale": "internal", - "requirements": ["pyprof2calltree==1.4.5", "guppy3==3.1.3", "objgraph==3.5.0"] + "requirements": [ + "pyprof2calltree==1.4.5", + "guppy3==3.1.3;python_version<'3.12'", + "objgraph==3.5.0" + ] } diff --git a/requirements_all.txt b/requirements_all.txt index 5657b1f4cc6a4..8dd61bc7d0cb0 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -926,6 +926,9 @@ gspread==5.5.0 # homeassistant.components.gstreamer gstreamer-player==1.1.2 +# homeassistant.components.profiler +guppy3==3.1.3;python_version<'3.12' + # homeassistant.components.iaqualink h2==4.1.0 @@ -1313,6 +1316,9 @@ oasatelematics==0.3 # homeassistant.components.google oauth2client==4.1.3 +# homeassistant.components.profiler +objgraph==3.5.0 + # homeassistant.components.garages_amsterdam odp-amsterdam==5.3.1 @@ -1930,6 +1936,9 @@ pyplaato==0.0.18 # homeassistant.components.point pypoint==2.3.2 +# homeassistant.components.profiler +pyprof2calltree==1.4.5 + # homeassistant.components.prosegur pyprosegur==0.0.9 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index fc7ad4eeb5576..b409bf058a9c3 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -727,6 +727,9 @@ growattServer==1.3.0 # homeassistant.components.google_sheets gspread==5.5.0 +# homeassistant.components.profiler +guppy3==3.1.3;python_version<'3.12' + # homeassistant.components.iaqualink h2==4.1.0 @@ -1015,6 +1018,9 @@ numpy==1.26.0 # homeassistant.components.google oauth2client==4.1.3 +# homeassistant.components.profiler +objgraph==3.5.0 + # homeassistant.components.garages_amsterdam odp-amsterdam==5.3.1 @@ -1452,6 +1458,9 @@ pyplaato==0.0.18 # homeassistant.components.point pypoint==2.3.2 +# homeassistant.components.profiler +pyprof2calltree==1.4.5 + # homeassistant.components.prosegur pyprosegur==0.0.9 diff --git a/tests/components/profiler/conftest.py b/tests/components/profiler/conftest.py deleted file mode 100644 index b93cb082fd266..0000000000000 --- a/tests/components/profiler/conftest.py +++ /dev/null @@ -1,3 +0,0 @@ -"""Skip test collection.""" - -collect_ignore_glob = ["test_*.py"] diff --git a/tests/components/profiler/test_init.py b/tests/components/profiler/test_init.py index 7c2aeb2a29acd..01f4c4ff510c7 100644 --- a/tests/components/profiler/test_init.py +++ b/tests/components/profiler/test_init.py @@ -3,6 +3,7 @@ from functools import lru_cache import os from pathlib import Path +import sys from unittest.mock import patch from lru import LRU # pylint: disable=no-name-in-module @@ -63,6 +64,9 @@ def _mock_path(filename: str) -> str: await hass.async_block_till_done() +@pytest.mark.skipif( + sys.version_info >= (3, 12), reason="not yet available on Python 3.12" +) async def test_memory_usage(hass: HomeAssistant, tmp_path: Path) -> None: """Test we can setup and the service is registered.""" test_dir = tmp_path / "profiles" @@ -94,6 +98,24 @@ def _mock_path(filename: str) -> str: await hass.async_block_till_done() +@pytest.mark.skipif(sys.version_info < (3, 12), reason="still works on python 3.11") +async def test_memory_usage_py312(hass: HomeAssistant, tmp_path: Path) -> None: + """Test raise an error on python3.11.""" + entry = MockConfigEntry(domain=DOMAIN) + entry.add_to_hass(hass) + + assert await hass.config_entries.async_setup(entry.entry_id) + await hass.async_block_till_done() + assert hass.services.has_service(DOMAIN, SERVICE_MEMORY) + with pytest.raises( + HomeAssistantError, + match="Memory profiling is not supported on Python 3.12. Please use Python 3.11.", + ): + await hass.services.async_call( + DOMAIN, SERVICE_MEMORY, {CONF_SECONDS: 0.000001}, blocking=True + ) + + async def test_object_growth_logging( hass: HomeAssistant, caplog: pytest.LogCaptureFixture ) -> None: From 6b70847ac94ed750e6773e9cfc3207968fdbfd9c Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 10 Oct 2023 01:35:03 +0200 Subject: [PATCH 12/20] Modify Python Scripts --- .../components/python_script/__init__.py | 31 ++++++++++++------- .../components/python_script/manifest.json | 3 +- requirements_all.txt | 3 ++ requirements_test_all.txt | 3 ++ tests/components/python_script/conftest.py | 6 ++-- 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/homeassistant/components/python_script/__init__.py b/homeassistant/components/python_script/__init__.py index 10751d28c0665..b96f32b71ef50 100644 --- a/homeassistant/components/python_script/__init__.py +++ b/homeassistant/components/python_script/__init__.py @@ -3,20 +3,9 @@ import glob import logging import os +import sys import time -from RestrictedPython import ( - compile_restricted_exec, - limited_builtins, - safe_builtins, - utility_builtins, -) -from RestrictedPython.Eval import default_guarded_getitem -from RestrictedPython.Guards import ( - full_write_guard, - guarded_iter_unpack_sequence, - guarded_unpack_sequence, -) import voluptuous as vol from homeassistant.const import CONF_DESCRIPTION, CONF_NAME, SERVICE_RELOAD @@ -29,6 +18,20 @@ import homeassistant.util.dt as dt_util from homeassistant.util.yaml.loader import load_yaml +if sys.version_info < (3, 12): + from RestrictedPython import ( + compile_restricted_exec, + limited_builtins, + safe_builtins, + utility_builtins, + ) + from RestrictedPython.Eval import default_guarded_getitem + from RestrictedPython.Guards import ( + full_write_guard, + guarded_iter_unpack_sequence, + guarded_unpack_sequence, + ) + _LOGGER = logging.getLogger(__name__) DOMAIN = "python_script" @@ -82,6 +85,10 @@ class ScriptError(HomeAssistantError): def setup(hass: HomeAssistant, config: ConfigType) -> bool: """Initialize the Python script component.""" + if sys.version_info >= (3, 12): + raise HomeAssistantError( + "Python Scripts is not supported on Python 3.12. Please use Python 3.11." + ) path = hass.config.path(FOLDER) if not os.path.isdir(path): diff --git a/homeassistant/components/python_script/manifest.json b/homeassistant/components/python_script/manifest.json index 25da3c550e517..00e43b5d260b7 100644 --- a/homeassistant/components/python_script/manifest.json +++ b/homeassistant/components/python_script/manifest.json @@ -2,9 +2,8 @@ "domain": "python_script", "name": "Python Scripts", "codeowners": [], - "disabled": "Dependencies does not support Python 3.12", "documentation": "https://www.home-assistant.io/integrations/python_script", "loggers": ["RestrictedPython"], "quality_scale": "internal", - "requirements": ["RestrictedPython==6.2"] + "requirements": ["RestrictedPython==6.2;python_version<'3.12'"] } diff --git a/requirements_all.txt b/requirements_all.txt index 8dd61bc7d0cb0..63cc26cdf4423 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -121,6 +121,9 @@ PyXiaomiGateway==0.14.3 # homeassistant.components.rachio RachioPy==1.0.3 +# homeassistant.components.python_script +RestrictedPython==6.2;python_version<'3.12' + # homeassistant.components.remember_the_milk RtmAPI==0.7.2 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index b409bf058a9c3..7e5f5ad6b9cdd 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -108,6 +108,9 @@ PyXiaomiGateway==0.14.3 # homeassistant.components.rachio RachioPy==1.0.3 +# homeassistant.components.python_script +RestrictedPython==6.2;python_version<'3.12' + # homeassistant.components.remember_the_milk RtmAPI==0.7.2 diff --git a/tests/components/python_script/conftest.py b/tests/components/python_script/conftest.py index b93cb082fd266..05a518ad7f3bb 100644 --- a/tests/components/python_script/conftest.py +++ b/tests/components/python_script/conftest.py @@ -1,3 +1,5 @@ -"""Skip test collection.""" +"""Skip test collection for Python 3.12.""" +import sys -collect_ignore_glob = ["test_*.py"] +if sys.version_info >= (3, 12): + collect_ignore_glob = ["test_*.py"] From 3ae62ef61c5b2cfa15c898cc99dd5ab1444cd31c Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 10 Oct 2023 11:47:13 +0200 Subject: [PATCH 13/20] Modify Met Office --- homeassistant/components/metoffice/__init__.py | 12 +++++++++--- homeassistant/components/metoffice/data.py | 10 ++++++---- homeassistant/components/metoffice/helpers.py | 9 ++++++--- homeassistant/components/metoffice/manifest.json | 3 +-- requirements_all.txt | 3 +++ requirements_test_all.txt | 3 +++ tests/components/metoffice/conftest.py | 8 +++++--- 7 files changed, 33 insertions(+), 15 deletions(-) diff --git a/homeassistant/components/metoffice/__init__.py b/homeassistant/components/metoffice/__init__.py index 56bf5ee99cebc..c22bc86df8430 100644 --- a/homeassistant/components/metoffice/__init__.py +++ b/homeassistant/components/metoffice/__init__.py @@ -4,10 +4,9 @@ import asyncio import logging import re +import sys from typing import Any -import datapoint - from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONF_API_KEY, @@ -17,7 +16,7 @@ Platform, ) from homeassistant.core import HomeAssistant, callback -from homeassistant.exceptions import ConfigEntryNotReady +from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError from homeassistant.helpers import device_registry as dr, entity_registry as er from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.update_coordinator import DataUpdateCoordinator @@ -35,6 +34,9 @@ from .data import MetOfficeData from .helpers import fetch_data, fetch_site +if sys.version_info < (3, 12): + import datapoint + _LOGGER = logging.getLogger(__name__) PLATFORMS = [Platform.SENSOR, Platform.WEATHER] @@ -42,6 +44,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up a Met Office entry.""" + if sys.version_info >= (3, 12): + raise HomeAssistantError( + "Met Office is not supported on Python 3.12. Please use Python 3.11." + ) latitude = entry.data[CONF_LATITUDE] longitude = entry.data[CONF_LONGITUDE] diff --git a/homeassistant/components/metoffice/data.py b/homeassistant/components/metoffice/data.py index 4b2741ce0fbc2..8512dd4c7a65c 100644 --- a/homeassistant/components/metoffice/data.py +++ b/homeassistant/components/metoffice/data.py @@ -1,11 +1,13 @@ """Common Met Office Data class used by both sensor and entity.""" - +from __future__ import annotations from dataclasses import dataclass +import sys -from datapoint.Forecast import Forecast -from datapoint.Site import Site -from datapoint.Timestep import Timestep +if sys.version_info < (3, 12): + from datapoint.Forecast import Forecast + from datapoint.Site import Site + from datapoint.Timestep import Timestep @dataclass diff --git a/homeassistant/components/metoffice/helpers.py b/homeassistant/components/metoffice/helpers.py index cdd506790ef47..389462d573a2a 100644 --- a/homeassistant/components/metoffice/helpers.py +++ b/homeassistant/components/metoffice/helpers.py @@ -2,9 +2,7 @@ from __future__ import annotations import logging - -import datapoint -from datapoint.Site import Site +import sys from homeassistant.helpers.update_coordinator import UpdateFailed from homeassistant.util.dt import utcnow @@ -12,6 +10,11 @@ from .const import MODE_3HOURLY from .data import MetOfficeData +if sys.version_info < (3, 12): + import datapoint + from datapoint.Site import Site + + _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/metoffice/manifest.json b/homeassistant/components/metoffice/manifest.json index b16a68378aa7a..9291f22f3b770 100644 --- a/homeassistant/components/metoffice/manifest.json +++ b/homeassistant/components/metoffice/manifest.json @@ -3,9 +3,8 @@ "name": "Met Office", "codeowners": ["@MrHarcombe", "@avee87"], "config_flow": true, - "disabled": "Dependencies does not support Python 3.12", "documentation": "https://www.home-assistant.io/integrations/metoffice", "iot_class": "cloud_polling", "loggers": ["datapoint"], - "requirements": ["datapoint==0.9.8"] + "requirements": ["datapoint==0.9.8;python_version<'3.12'"] } diff --git a/requirements_all.txt b/requirements_all.txt index 63cc26cdf4423..d38e5a52ed3b4 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -635,6 +635,9 @@ crownstone-uart==2.1.0 # homeassistant.components.datadog datadog==0.15.0 +# homeassistant.components.metoffice +datapoint==0.9.8;python_version<'3.12' + # homeassistant.components.bluetooth dbus-fast==2.11.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 7e5f5ad6b9cdd..478a7c1356ea9 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -518,6 +518,9 @@ crownstone-uart==2.1.0 # homeassistant.components.datadog datadog==0.15.0 +# homeassistant.components.metoffice +datapoint==0.9.8;python_version<'3.12' + # homeassistant.components.bluetooth dbus-fast==2.11.1 diff --git a/tests/components/metoffice/conftest.py b/tests/components/metoffice/conftest.py index 0b82ac3fb7fab..1633fae5ee86e 100644 --- a/tests/components/metoffice/conftest.py +++ b/tests/components/metoffice/conftest.py @@ -1,11 +1,13 @@ """Fixtures for Met Office weather integration tests.""" -# ruff: noqa: F821 +import sys from unittest.mock import patch -# from datapoint.exceptions import APIException import pytest -collect_ignore_glob = ["test_*.py"] +if sys.version_info < (3, 12): + from datapoint.exceptions import APIException +else: + collect_ignore_glob = ["test_*.py"] @pytest.fixture From 3f8a56138fb082c3440467fae92fb35a59349bc6 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 10 Oct 2023 11:52:29 +0200 Subject: [PATCH 14/20] Modify Cisco Webex Teams --- .../components/cisco_webex_teams/manifest.json | 3 +-- homeassistant/components/cisco_webex_teams/notify.py | 11 ++++++++++- requirements_all.txt | 3 +++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/cisco_webex_teams/manifest.json b/homeassistant/components/cisco_webex_teams/manifest.json index 3d3d5e5774190..6f4e1ead956e2 100644 --- a/homeassistant/components/cisco_webex_teams/manifest.json +++ b/homeassistant/components/cisco_webex_teams/manifest.json @@ -2,9 +2,8 @@ "domain": "cisco_webex_teams", "name": "Cisco Webex Teams", "codeowners": ["@fbradyirl"], - "disabled": "Dependencies does not support Python 3.12", "documentation": "https://www.home-assistant.io/integrations/cisco_webex_teams", "iot_class": "cloud_push", "loggers": ["webexteamssdk"], - "requirements": ["webexteamssdk==1.1.1"] + "requirements": ["webexteamssdk==1.1.1;python_version<'3.12'"] } diff --git a/homeassistant/components/cisco_webex_teams/notify.py b/homeassistant/components/cisco_webex_teams/notify.py index be8710c709602..d2c75d78390b8 100644 --- a/homeassistant/components/cisco_webex_teams/notify.py +++ b/homeassistant/components/cisco_webex_teams/notify.py @@ -2,9 +2,9 @@ from __future__ import annotations import logging +import sys import voluptuous as vol -from webexteamssdk import ApiError, WebexTeamsAPI, exceptions from homeassistant.components.notify import ( ATTR_TITLE, @@ -13,9 +13,14 @@ ) from homeassistant.const import CONF_TOKEN from homeassistant.core import HomeAssistant +from homeassistant.exceptions import HomeAssistantError import homeassistant.helpers.config_validation as cv from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType +if sys.version_info < (3, 12): + from webexteamssdk import ApiError, WebexTeamsAPI, exceptions + + _LOGGER = logging.getLogger(__name__) CONF_ROOM_ID = "room_id" @@ -31,6 +36,10 @@ def get_service( discovery_info: DiscoveryInfoType | None = None, ) -> CiscoWebexTeamsNotificationService | None: """Get the CiscoWebexTeams notification service.""" + if sys.version_info >= (3, 12): + raise HomeAssistantError( + "Cisco Webex Teams is not supported on Python 3.12. Please use Python 3.11." + ) client = WebexTeamsAPI(access_token=config[CONF_TOKEN]) try: diff --git a/requirements_all.txt b/requirements_all.txt index d38e5a52ed3b4..905be3519b1b2 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2684,6 +2684,9 @@ watchdog==2.3.1 # homeassistant.components.waterfurnace waterfurnace==1.1.0 +# homeassistant.components.cisco_webex_teams +webexteamssdk==1.1.1;python_version<'3.12' + # homeassistant.components.assist_pipeline webrtc-noise-gain==1.2.3 From 94c03e61bd8459e3ddc797a4aff50b9dc18d752a Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 10 Oct 2023 11:57:09 +0200 Subject: [PATCH 15/20] Modify Apache Kafka --- homeassistant/components/apache_kafka/__init__.py | 11 ++++++++++- homeassistant/components/apache_kafka/manifest.json | 1 - requirements_all.txt | 3 +++ requirements_test_all.txt | 3 +++ tests/components/apache_kafka/conftest.py | 4 +++- 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/apache_kafka/__init__.py b/homeassistant/components/apache_kafka/__init__.py index 38a70b450ab5c..c974735791e04 100644 --- a/homeassistant/components/apache_kafka/__init__.py +++ b/homeassistant/components/apache_kafka/__init__.py @@ -1,8 +1,8 @@ """Support for Apache Kafka.""" from datetime import datetime import json +import sys -from aiokafka import AIOKafkaProducer import voluptuous as vol from homeassistant.const import ( @@ -16,11 +16,16 @@ STATE_UNKNOWN, ) from homeassistant.core import HomeAssistant +from homeassistant.exceptions import HomeAssistantError import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entityfilter import FILTER_SCHEMA from homeassistant.helpers.typing import ConfigType from homeassistant.util import ssl as ssl_util +if sys.version_info < (3, 12): + from aiokafka import AIOKafkaProducer + + DOMAIN = "apache_kafka" CONF_FILTER = "filter" @@ -49,6 +54,10 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Activate the Apache Kafka integration.""" + if sys.version_info >= (3, 12): + raise HomeAssistantError( + "Apache Kafka is not supported on Python 3.12. Please use Python 3.11." + ) conf = config[DOMAIN] kafka = hass.data[DOMAIN] = KafkaManager( diff --git a/homeassistant/components/apache_kafka/manifest.json b/homeassistant/components/apache_kafka/manifest.json index 9a20a5750904b..11cb0ece7acc3 100644 --- a/homeassistant/components/apache_kafka/manifest.json +++ b/homeassistant/components/apache_kafka/manifest.json @@ -2,7 +2,6 @@ "domain": "apache_kafka", "name": "Apache Kafka", "codeowners": ["@bachya"], - "disabled": "Dependencies does not support Python 3.12", "documentation": "https://www.home-assistant.io/integrations/apache_kafka", "iot_class": "local_push", "loggers": ["aiokafka", "kafka_python"], diff --git a/requirements_all.txt b/requirements_all.txt index 905be3519b1b2..52cc471dcae3a 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -261,6 +261,9 @@ aiohue==4.7.0 # homeassistant.components.imap aioimaplib==1.0.1 +# homeassistant.components.apache_kafka +aiokafka==0.7.2 + # homeassistant.components.kef aiokef==0.2.16 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 478a7c1356ea9..df238439f4a9c 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -239,6 +239,9 @@ aiohue==4.7.0 # homeassistant.components.imap aioimaplib==1.0.1 +# homeassistant.components.apache_kafka +aiokafka==0.7.2 + # homeassistant.components.lifx aiolifx-effects==0.3.2 diff --git a/tests/components/apache_kafka/conftest.py b/tests/components/apache_kafka/conftest.py index b93cb082fd266..9391ccdd380d7 100644 --- a/tests/components/apache_kafka/conftest.py +++ b/tests/components/apache_kafka/conftest.py @@ -1,3 +1,5 @@ """Skip test collection.""" +import sys -collect_ignore_glob = ["test_*.py"] +if sys.version_info >= (3, 12): + collect_ignore_glob = ["test_*.py"] From 3b20b8d138e605bd3a44458847a359dd56bbcf40 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 10 Oct 2023 12:03:50 +0200 Subject: [PATCH 16/20] Modify Uonet+ Vulcan --- homeassistant/components/vulcan/__init__.py | 15 +++++++++++++-- homeassistant/components/vulcan/manifest.json | 1 - requirements_all.txt | 3 +++ requirements_test_all.txt | 3 +++ tests/components/vulcan/conftest.py | 4 +++- 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/vulcan/__init__.py b/homeassistant/components/vulcan/__init__.py index 0bfd09d590d63..b52b4181510ea 100644 --- a/homeassistant/components/vulcan/__init__.py +++ b/homeassistant/components/vulcan/__init__.py @@ -1,21 +1,32 @@ """The Vulcan component.""" +import sys from aiohttp import ClientConnectorError -from vulcan import Account, Keystore, UnauthorizedCertificateException, Vulcan from homeassistant.config_entries import ConfigEntry from homeassistant.const import Platform from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady +from homeassistant.exceptions import ( + ConfigEntryAuthFailed, + ConfigEntryNotReady, + HomeAssistantError, +) from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import DOMAIN +if sys.version_info < (3, 12): + from vulcan import Account, Keystore, UnauthorizedCertificateException, Vulcan + PLATFORMS = [Platform.CALENDAR] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Uonet+ Vulcan integration.""" + if sys.version_info >= (3, 12): + raise HomeAssistantError( + "Uonet+ Vulcan is not supported on Python 3.12. Please use Python 3.11." + ) hass.data.setdefault(DOMAIN, {}) try: keystore = Keystore.load(entry.data["keystore"]) diff --git a/homeassistant/components/vulcan/manifest.json b/homeassistant/components/vulcan/manifest.json index d732310e1349f..fea87480cf0de 100644 --- a/homeassistant/components/vulcan/manifest.json +++ b/homeassistant/components/vulcan/manifest.json @@ -3,7 +3,6 @@ "name": "Uonet+ Vulcan", "codeowners": ["@Antoni-Czaplicki"], "config_flow": true, - "disabled": "Dependencies does not support Python 3.12", "documentation": "https://www.home-assistant.io/integrations/vulcan", "iot_class": "cloud_polling", "quality_scale": "silver", diff --git a/requirements_all.txt b/requirements_all.txt index 52cc471dcae3a..a89b075d86d2e 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2671,6 +2671,9 @@ vsure==2.6.6 # homeassistant.components.vasttrafik vtjp==0.1.14 +# homeassistant.components.vulcan +vulcan-api==2.3.0 + # homeassistant.components.vultr vultr==0.1.2 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index df238439f4a9c..3813c001ff725 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1983,6 +1983,9 @@ volvooncall==0.10.3 # homeassistant.components.verisure vsure==2.6.6 +# homeassistant.components.vulcan +vulcan-api==2.3.0 + # homeassistant.components.vultr vultr==0.1.2 diff --git a/tests/components/vulcan/conftest.py b/tests/components/vulcan/conftest.py index 9b8920595be96..05a518ad7f3bb 100644 --- a/tests/components/vulcan/conftest.py +++ b/tests/components/vulcan/conftest.py @@ -1,3 +1,5 @@ """Skip test collection for Python 3.12.""" +import sys -collect_ignore_glob = ["test_*.py"] +if sys.version_info >= (3, 12): + collect_ignore_glob = ["test_*.py"] From 9a135654ee4700283ec474bcf75f9b9cac3d12cf Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 10 Oct 2023 12:27:41 +0200 Subject: [PATCH 17/20] Modify Brother Printer + SNMP --- homeassistant/components/brother/__init__.py | 15 ++- .../components/brother/manifest.json | 1 - homeassistant/components/brother/utils.py | 10 +- .../components/snmp/device_tracker.py | 13 ++- homeassistant/components/snmp/manifest.json | 1 - homeassistant/components/snmp/sensor.py | 34 ++++--- homeassistant/components/snmp/switch.py | 91 ++++++++++--------- requirements_all.txt | 6 ++ requirements_test_all.txt | 6 ++ tests/components/brother/__init__.py | 6 +- tests/components/brother/conftest.py | 4 +- tests/components/snmp/conftest.py | 4 +- 12 files changed, 123 insertions(+), 68 deletions(-) diff --git a/homeassistant/components/brother/__init__.py b/homeassistant/components/brother/__init__.py index 27ac97a27dc8c..0f8f94c73c4c3 100644 --- a/homeassistant/components/brother/__init__.py +++ b/homeassistant/components/brother/__init__.py @@ -4,18 +4,23 @@ from asyncio import timeout from datetime import timedelta import logging - -from brother import Brother, BrotherSensors, SnmpError, UnsupportedModelError +import sys +from typing import Any from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_HOST, CONF_TYPE, Platform from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ConfigEntryNotReady +from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from .const import DATA_CONFIG_ENTRY, DOMAIN, SNMP from .utils import get_snmp_engine +if sys.version_info < (3, 12): + from brother import Brother, BrotherSensors, SnmpError, UnsupportedModelError +else: + BrotherSensors = Any + PLATFORMS = [Platform.SENSOR] SCAN_INTERVAL = timedelta(seconds=30) @@ -25,6 +30,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Brother from a config entry.""" + if sys.version_info >= (3, 12): + raise HomeAssistantError( + "Brother Printer is not supported on Python 3.12. Please use Python 3.11." + ) host = entry.data[CONF_HOST] printer_type = entry.data[CONF_TYPE] diff --git a/homeassistant/components/brother/manifest.json b/homeassistant/components/brother/manifest.json index 7a40fb63bc7a1..cba44b68c6ac4 100644 --- a/homeassistant/components/brother/manifest.json +++ b/homeassistant/components/brother/manifest.json @@ -3,7 +3,6 @@ "name": "Brother Printer", "codeowners": ["@bieniu"], "config_flow": true, - "disabled": "Dependencies does not support Python 3.12", "documentation": "https://www.home-assistant.io/integrations/brother", "integration_type": "device", "iot_class": "local_polling", diff --git a/homeassistant/components/brother/utils.py b/homeassistant/components/brother/utils.py index e421be52154f5..cd472b9b75469 100644 --- a/homeassistant/components/brother/utils.py +++ b/homeassistant/components/brother/utils.py @@ -1,8 +1,8 @@ """Brother helpers functions.""" -import logging +from __future__ import annotations -import pysnmp.hlapi.asyncio as hlapi -from pysnmp.hlapi.asyncio.cmdgen import lcd +import logging +import sys from homeassistant.const import EVENT_HOMEASSISTANT_STOP from homeassistant.core import Event, HomeAssistant, callback @@ -10,6 +10,10 @@ from .const import DOMAIN, SNMP +if sys.version_info < (3, 12): + import pysnmp.hlapi.asyncio as hlapi + from pysnmp.hlapi.asyncio.cmdgen import lcd + _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/snmp/device_tracker.py b/homeassistant/components/snmp/device_tracker.py index 696b079fd5e5f..7ca31bae61899 100644 --- a/homeassistant/components/snmp/device_tracker.py +++ b/homeassistant/components/snmp/device_tracker.py @@ -3,9 +3,8 @@ import binascii import logging +import sys -from pysnmp.entity import config as cfg -from pysnmp.entity.rfc3413.oneliner import cmdgen import voluptuous as vol from homeassistant.components.device_tracker import ( @@ -15,6 +14,7 @@ ) from homeassistant.const import CONF_HOST from homeassistant.core import HomeAssistant +from homeassistant.exceptions import HomeAssistantError import homeassistant.helpers.config_validation as cv from homeassistant.helpers.typing import ConfigType @@ -26,6 +26,11 @@ DEFAULT_COMMUNITY, ) +if sys.version_info < (3, 12): + from pysnmp.entity import config as cfg + from pysnmp.entity.rfc3413.oneliner import cmdgen + + _LOGGER = logging.getLogger(__name__) PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend( @@ -41,6 +46,10 @@ def get_scanner(hass: HomeAssistant, config: ConfigType) -> SnmpScanner | None: """Validate the configuration and return an SNMP scanner.""" + if sys.version_info >= (3, 12): + raise HomeAssistantError( + "SNMP is not supported on Python 3.12. Please use Python 3.11." + ) scanner = SnmpScanner(config[DOMAIN]) return scanner if scanner.success_init else None diff --git a/homeassistant/components/snmp/manifest.json b/homeassistant/components/snmp/manifest.json index cb9fd4702ad02..324a1e493661c 100644 --- a/homeassistant/components/snmp/manifest.json +++ b/homeassistant/components/snmp/manifest.json @@ -2,7 +2,6 @@ "domain": "snmp", "name": "SNMP", "codeowners": [], - "disabled": "Dependencies does not support Python 3.12", "documentation": "https://www.home-assistant.io/integrations/snmp", "iot_class": "local_polling", "loggers": ["pyasn1", "pysmi", "pysnmp"], diff --git a/homeassistant/components/snmp/sensor.py b/homeassistant/components/snmp/sensor.py index a5915183ad0c9..58cd12d611f46 100644 --- a/homeassistant/components/snmp/sensor.py +++ b/homeassistant/components/snmp/sensor.py @@ -3,20 +3,8 @@ from datetime import timedelta import logging +import sys -from pysnmp.error import PySnmpError -import pysnmp.hlapi.asyncio as hlapi -from pysnmp.hlapi.asyncio import ( - CommunityData, - ContextData, - ObjectIdentity, - ObjectType, - SnmpEngine, - Udp6TransportTarget, - UdpTransportTarget, - UsmUserData, - getCmd, -) import voluptuous as vol from homeassistant.components.sensor import CONF_STATE_CLASS, PLATFORM_SCHEMA @@ -33,6 +21,7 @@ STATE_UNKNOWN, ) from homeassistant.core import HomeAssistant +from homeassistant.exceptions import HomeAssistantError import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.template import Template @@ -67,6 +56,21 @@ SNMP_VERSIONS, ) +if sys.version_info < (3, 12): + from pysnmp.error import PySnmpError + import pysnmp.hlapi.asyncio as hlapi + from pysnmp.hlapi.asyncio import ( + CommunityData, + ContextData, + ObjectIdentity, + ObjectType, + SnmpEngine, + Udp6TransportTarget, + UdpTransportTarget, + UsmUserData, + getCmd, + ) + _LOGGER = logging.getLogger(__name__) SCAN_INTERVAL = timedelta(seconds=10) @@ -111,6 +115,10 @@ async def async_setup_platform( discovery_info: DiscoveryInfoType | None = None, ) -> None: """Set up the SNMP sensor.""" + if sys.version_info >= (3, 12): + raise HomeAssistantError( + "SNMP is not supported on Python 3.12. Please use Python 3.11." + ) host = config.get(CONF_HOST) port = config.get(CONF_PORT) community = config.get(CONF_COMMUNITY) diff --git a/homeassistant/components/snmp/switch.py b/homeassistant/components/snmp/switch.py index d0fe393d55083..e94c699160115 100644 --- a/homeassistant/components/snmp/switch.py +++ b/homeassistant/components/snmp/switch.py @@ -2,34 +2,9 @@ from __future__ import annotations import logging +import sys from typing import Any -import pysnmp.hlapi.asyncio as hlapi -from pysnmp.hlapi.asyncio import ( - CommunityData, - ContextData, - ObjectIdentity, - ObjectType, - SnmpEngine, - UdpTransportTarget, - UsmUserData, - getCmd, - setCmd, -) -from pysnmp.proto.rfc1902 import ( - Counter32, - Counter64, - Gauge32, - Integer, - Integer32, - IpAddress, - Null, - ObjectIdentifier, - OctetString, - Opaque, - TimeTicks, - Unsigned32, -) import voluptuous as vol from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity @@ -42,6 +17,7 @@ CONF_USERNAME, ) from homeassistant.core import HomeAssistant +from homeassistant.exceptions import HomeAssistantError import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType @@ -67,6 +43,34 @@ SNMP_VERSIONS, ) +if sys.version_info < (3, 12): + import pysnmp.hlapi.asyncio as hlapi + from pysnmp.hlapi.asyncio import ( + CommunityData, + ContextData, + ObjectIdentity, + ObjectType, + SnmpEngine, + UdpTransportTarget, + UsmUserData, + getCmd, + setCmd, + ) + from pysnmp.proto.rfc1902 import ( + Counter32, + Counter64, + Gauge32, + Integer, + Integer32, + IpAddress, + Null, + ObjectIdentifier, + OctetString, + Opaque, + TimeTicks, + Unsigned32, + ) + _LOGGER = logging.getLogger(__name__) CONF_COMMAND_OID = "command_oid" @@ -77,21 +81,22 @@ DEFAULT_PAYLOAD_OFF = 0 DEFAULT_PAYLOAD_ON = 1 -MAP_SNMP_VARTYPES = { - "Counter32": Counter32, - "Counter64": Counter64, - "Gauge32": Gauge32, - "Integer32": Integer32, - "Integer": Integer, - "IpAddress": IpAddress, - "Null": Null, - # some work todo to support tuple ObjectIdentifier, this just supports str - "ObjectIdentifier": ObjectIdentifier, - "OctetString": OctetString, - "Opaque": Opaque, - "TimeTicks": TimeTicks, - "Unsigned32": Unsigned32, -} +if sys.version_info < (3, 12): + MAP_SNMP_VARTYPES = { + "Counter32": Counter32, + "Counter64": Counter64, + "Gauge32": Gauge32, + "Integer32": Integer32, + "Integer": Integer, + "IpAddress": IpAddress, + "Null": Null, + # some work todo to support tuple ObjectIdentifier, this just supports str + "ObjectIdentifier": ObjectIdentifier, + "OctetString": OctetString, + "Opaque": Opaque, + "TimeTicks": TimeTicks, + "Unsigned32": Unsigned32, + } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { @@ -127,6 +132,10 @@ async def async_setup_platform( discovery_info: DiscoveryInfoType | None = None, ) -> None: """Set up the SNMP switch.""" + if sys.version_info >= (3, 12): + raise HomeAssistantError( + "SNMP is not supported on Python 3.12. Please use Python 3.11." + ) name = config.get(CONF_NAME) host = config.get(CONF_HOST) port = config.get(CONF_PORT) diff --git a/requirements_all.txt b/requirements_all.txt index a89b075d86d2e..6ee1b939123ec 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -568,6 +568,9 @@ boto3==1.28.17 # homeassistant.components.broadlink broadlink==0.18.3 +# homeassistant.components.brother +brother==2.3.0 + # homeassistant.components.brottsplatskartan brottsplatskartan==0.0.1 @@ -2040,6 +2043,9 @@ pysmartthings==0.7.8 # homeassistant.components.edl21 pysml==0.0.12 +# homeassistant.components.snmp +pysnmplib==5.0.21 + # homeassistant.components.snooz pysnooz==0.8.6 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 3813c001ff725..834af20db776f 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -478,6 +478,9 @@ boschshcpy==0.2.57 # homeassistant.components.broadlink broadlink==0.18.3 +# homeassistant.components.brother +brother==2.3.0 + # homeassistant.components.brottsplatskartan brottsplatskartan==0.0.1 @@ -1541,6 +1544,9 @@ pysmartthings==0.7.8 # homeassistant.components.edl21 pysml==0.0.12 +# homeassistant.components.snmp +pysnmplib==5.0.21 + # homeassistant.components.snooz pysnooz==0.8.6 diff --git a/tests/components/brother/__init__.py b/tests/components/brother/__init__.py index 8dd27ffc88710..3176fa7fc28fd 100644 --- a/tests/components/brother/__init__.py +++ b/tests/components/brother/__init__.py @@ -1,14 +1,16 @@ """Tests for Brother Printer integration.""" -# ruff: noqa: F821 import json +import sys from unittest.mock import patch -# from homeassistant.components.brother.const import DOMAIN from homeassistant.const import CONF_HOST, CONF_TYPE from homeassistant.core import HomeAssistant from tests.common import MockConfigEntry, load_fixture +if sys.version_info < (3, 12): + from homeassistant.components.brother.const import DOMAIN + async def init_integration( hass: HomeAssistant, skip_setup: bool = False diff --git a/tests/components/brother/conftest.py b/tests/components/brother/conftest.py index a667b37c59f3a..558b3b8ac3eb8 100644 --- a/tests/components/brother/conftest.py +++ b/tests/components/brother/conftest.py @@ -1,10 +1,12 @@ """Test fixtures for brother.""" from collections.abc import Generator +import sys from unittest.mock import AsyncMock, patch import pytest -collect_ignore_glob = ["test_*.py"] +if sys.version_info >= (3, 12): + collect_ignore_glob = ["test_*.py"] @pytest.fixture diff --git a/tests/components/snmp/conftest.py b/tests/components/snmp/conftest.py index 9b8920595be96..05a518ad7f3bb 100644 --- a/tests/components/snmp/conftest.py +++ b/tests/components/snmp/conftest.py @@ -1,3 +1,5 @@ """Skip test collection for Python 3.12.""" +import sys -collect_ignore_glob = ["test_*.py"] +if sys.version_info >= (3, 12): + collect_ignore_glob = ["test_*.py"] From 5f0a1712190e4db3bfc07cc340a5f71d400e9ea3 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 10 Oct 2023 12:34:07 +0200 Subject: [PATCH 18/20] Revert "Add classifer for 3.12" --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 500b08dd72d24..57996a2240b1a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,6 @@ classifiers = [ "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", "Topic :: Home Automation", ] requires-python = ">=3.11.0" From 0f01ccfa4375b604a76f937ab22237194c99bb1a Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 10 Oct 2023 14:06:00 +0200 Subject: [PATCH 19/20] Update RestrictedPython to 7.0a1.dev0 for 3.12 --- .../components/python_script/__init__.py | 31 +++++++------------ .../components/python_script/manifest.json | 5 ++- requirements_all.txt | 3 ++ requirements_test_all.txt | 3 ++ tests/components/python_script/conftest.py | 5 --- 5 files changed, 22 insertions(+), 25 deletions(-) delete mode 100644 tests/components/python_script/conftest.py diff --git a/homeassistant/components/python_script/__init__.py b/homeassistant/components/python_script/__init__.py index b96f32b71ef50..10751d28c0665 100644 --- a/homeassistant/components/python_script/__init__.py +++ b/homeassistant/components/python_script/__init__.py @@ -3,9 +3,20 @@ import glob import logging import os -import sys import time +from RestrictedPython import ( + compile_restricted_exec, + limited_builtins, + safe_builtins, + utility_builtins, +) +from RestrictedPython.Eval import default_guarded_getitem +from RestrictedPython.Guards import ( + full_write_guard, + guarded_iter_unpack_sequence, + guarded_unpack_sequence, +) import voluptuous as vol from homeassistant.const import CONF_DESCRIPTION, CONF_NAME, SERVICE_RELOAD @@ -18,20 +29,6 @@ import homeassistant.util.dt as dt_util from homeassistant.util.yaml.loader import load_yaml -if sys.version_info < (3, 12): - from RestrictedPython import ( - compile_restricted_exec, - limited_builtins, - safe_builtins, - utility_builtins, - ) - from RestrictedPython.Eval import default_guarded_getitem - from RestrictedPython.Guards import ( - full_write_guard, - guarded_iter_unpack_sequence, - guarded_unpack_sequence, - ) - _LOGGER = logging.getLogger(__name__) DOMAIN = "python_script" @@ -85,10 +82,6 @@ class ScriptError(HomeAssistantError): def setup(hass: HomeAssistant, config: ConfigType) -> bool: """Initialize the Python script component.""" - if sys.version_info >= (3, 12): - raise HomeAssistantError( - "Python Scripts is not supported on Python 3.12. Please use Python 3.11." - ) path = hass.config.path(FOLDER) if not os.path.isdir(path): diff --git a/homeassistant/components/python_script/manifest.json b/homeassistant/components/python_script/manifest.json index 00e43b5d260b7..bd034053a346d 100644 --- a/homeassistant/components/python_script/manifest.json +++ b/homeassistant/components/python_script/manifest.json @@ -5,5 +5,8 @@ "documentation": "https://www.home-assistant.io/integrations/python_script", "loggers": ["RestrictedPython"], "quality_scale": "internal", - "requirements": ["RestrictedPython==6.2;python_version<'3.12'"] + "requirements": [ + "RestrictedPython==6.2;python_version<'3.12'", + "RestrictedPython==7.0a1.dev0;python_version>='3.12'" + ] } diff --git a/requirements_all.txt b/requirements_all.txt index 6ee1b939123ec..531d775220031 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -124,6 +124,9 @@ RachioPy==1.0.3 # homeassistant.components.python_script RestrictedPython==6.2;python_version<'3.12' +# homeassistant.components.python_script +RestrictedPython==7.0a1.dev0;python_version>='3.12' + # homeassistant.components.remember_the_milk RtmAPI==0.7.2 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 834af20db776f..099c9d7a29a06 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -111,6 +111,9 @@ RachioPy==1.0.3 # homeassistant.components.python_script RestrictedPython==6.2;python_version<'3.12' +# homeassistant.components.python_script +RestrictedPython==7.0a1.dev0;python_version>='3.12' + # homeassistant.components.remember_the_milk RtmAPI==0.7.2 diff --git a/tests/components/python_script/conftest.py b/tests/components/python_script/conftest.py deleted file mode 100644 index 05a518ad7f3bb..0000000000000 --- a/tests/components/python_script/conftest.py +++ /dev/null @@ -1,5 +0,0 @@ -"""Skip test collection for Python 3.12.""" -import sys - -if sys.version_info >= (3, 12): - collect_ignore_glob = ["test_*.py"] From dc0ebdc35aec3c1c817691b2724a63b044787e78 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 10 Oct 2023 14:24:31 +0200 Subject: [PATCH 20/20] Update warnings filter --- pyproject.toml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 57996a2240b1a..15a33f2cbf382 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -504,7 +504,7 @@ filterwarnings = [ "ignore:python-telegram-bot is using upstream urllib3:UserWarning:telegram.utils.request", # https://github.com/ludeeus/pytraccar/pull/15 - >1.0.0 "ignore:datetime.*utcnow\\(\\) is deprecated and scheduled for removal:DeprecationWarning:pytraccar.client", - # https://github.com/zopefoundation/RestrictedPython/pull/259 - >=7.0a1.dev0 + # https://github.com/zopefoundation/RestrictedPython/pull/259 - >7.0a1.dev0 "ignore:ast\\.(Str|Num) is deprecated and will be removed in Python 3.14:DeprecationWarning:RestrictedPython.transformer", # https://github.com/grahamwetzler/smart-meter-texas/pull/143 - >0.5.3 "ignore:ssl.OP_NO_SSL\\*/ssl.OP_NO_TLS\\* options are deprecated:DeprecationWarning:smart_meter_texas", @@ -519,22 +519,22 @@ filterwarnings = [ # Locale changes might take some time to resolve upstream "ignore:Use setlocale\\(\\), getencoding\\(\\) and getlocale\\(\\) instead:DeprecationWarning:homematicip.base.base_connection", "ignore:Use setlocale\\(\\), getencoding\\(\\) and getlocale\\(\\) instead:DeprecationWarning:micloud.micloud", - # Wrong stacklevel - # https://bugs.launchpad.net/beautifulsoup/+bug/2034451 - "ignore:It looks like you're parsing an XML document using an HTML parser:UserWarning:bs4.builder", - # New in aiohttp - v3.9.0 - "ignore:It is recommended to use web.AppKey instances for keys:UserWarning:(homeassistant|tests|aiohttp_cors)", - # https://github.com/protocolbuffers/protobuf - v4.24.3 + # https://github.com/protocolbuffers/protobuf - v4.24.4 "ignore:datetime.*utcfromtimestamp\\(\\) is deprecated and scheduled for removal:DeprecationWarning:google.protobuf.internal.well_known_types", "ignore:Type google._upb._message.(Message|Scalar)MapContainer uses PyType_Spec with a metaclass that has custom tp_new. .* Python 3.14:DeprecationWarning", - # https://github.com/googleapis/google-auth-library-python/blob/v2.23.2/google/auth/_helpers.py#L95 - v2.23.2 + # https://github.com/googleapis/google-auth-library-python/blob/v2.23.3/google/auth/_helpers.py#L95 - v2.23.3 "ignore:datetime.*utcnow\\(\\) is deprecated:DeprecationWarning:google.auth._helpers", # https://github.com/googleapis/proto-plus-python/blob/v1.22.3/proto/datetime_helpers.py#L24 - v1.22.3 "ignore:datetime.*utcfromtimestamp\\(\\) is deprecated:DeprecationWarning:proto.datetime_helpers", - # https://github.com/MatsNl/pyatag/issues/11 -> no recent activity - v0.3.6.2 + # https://github.com/MatsNl/pyatag/issues/11 - v0.3.7.1 "ignore:datetime.*utcnow\\(\\) is deprecated and scheduled for removal:DeprecationWarning:pyatag.gateway", - # https://github.com/Python-MyQ/Python-MyQ -> fork - v3.1.11 + # https://github.com/Python-MyQ/Python-MyQ - v3.1.11 "ignore:datetime.*utcnow\\(\\) is deprecated and scheduled for removal:DeprecationWarning:pymyq.(api|account)", + # Wrong stacklevel + # https://bugs.launchpad.net/beautifulsoup/+bug/2034451 + "ignore:It looks like you're parsing an XML document using an HTML parser:UserWarning:bs4.builder", + # New in aiohttp - v3.9.0 + "ignore:It is recommended to use web.AppKey instances for keys:UserWarning:(homeassistant|tests|aiohttp_cors)", # -- unmaintained projects, last release about 2+ years # https://pypi.org/project/agent-py/ - v0.0.23 - 2020-06-04