From 9855e68d3da4d876ada4c6d98f8645a3bfa47d37 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Mon, 9 Jan 2023 10:03:30 +0100 Subject: [PATCH 1/5] Prepare Python 3.11 --- .github/workflows/verify.yml | 4 ++-- pyproject.toml | 5 +++-- scripts/python-venv.sh | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index aa2d39c32..f2627a234 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -160,7 +160,7 @@ jobs: needs: commitcheck strategy: matrix: - python-version: [3.9, "3.10"] + python-version: [3.9, "3.10", "3.11"] steps: - name: Check out committed code uses: actions/checkout@v3 @@ -199,7 +199,7 @@ jobs: needs: prepare-test-cache strategy: matrix: - python-version: [3.9, "3.10"] + python-version: [3.9, "3.10", "3.11"] steps: - name: Check out committed code diff --git a/pyproject.toml b/pyproject.toml index 4377dff0c..0adb433c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,6 +16,7 @@ classifiers = [ "Operating System :: OS Independent", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Topic :: Home Automation", ] authors = [ @@ -50,7 +51,7 @@ include-package-data = true include = ["plugwise*"] [tool.black] -target-version = ["py39", "py310"] +target-version = ["py39", "py310", "py311"] exclude = 'generated' [tool.isort] @@ -187,7 +188,7 @@ norecursedirs = [ ] [tool.mypy] -python_version = "3.10" +python_version = "3.11" show_error_codes = true follow_imports = "silent" ignore_missing_imports = true diff --git a/scripts/python-venv.sh b/scripts/python-venv.sh index f2d14fbee..743ad570a 100755 --- a/scripts/python-venv.sh +++ b/scripts/python-venv.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -eu -pyversions=(3.10 3.9) +pyversions=(3.11 3.10 3.9) my_path=$(git rev-parse --show-toplevel) my_venv=${my_path}/venv From 9714b664bab0239cf91c8084936433914bd90dd3 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 25 Feb 2023 13:00:26 +0100 Subject: [PATCH 2/5] Trigger From d6e8078f6431e48a22ac7d5f5d0ce95e2c898b51 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 25 Feb 2023 13:12:23 +0100 Subject: [PATCH 3/5] Bump --- .github/workflows/verify.yml | 2 +- .pre-commit-config.yaml | 4 ++-- plugwise/helper.py | 7 +++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index f2627a234..9072713b5 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -4,7 +4,7 @@ name: Latest commit env: - CACHE_VERSION: 2 + CACHE_VERSION: 3 DEFAULT_PYTHON: "3.10" PRE_COMMIT_HOME: ~/.cache/pre-commit diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b58701f84..6ec052f35 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,7 +9,7 @@ default_language_version: repos: # Run manually in CI skipping the branch checks - repo: https://github.com/PyCQA/isort - rev: 5.11.4 + rev: 5.12.0 hooks: - id: isort - repo: https://github.com/pre-commit/pre-commit-hooks @@ -26,7 +26,7 @@ repos: - id: pyupgrade args: [--py39-plus] - repo: https://github.com/psf/black - rev: 22.12.0 + rev: 23.1.0 hooks: - id: black args: diff --git a/plugwise/helper.py b/plugwise/helper.py index 62b8f7597..1262fc027 100644 --- a/plugwise/helper.py +++ b/plugwise/helper.py @@ -225,7 +225,6 @@ def __init__( ): """Set the constructor for this class.""" if not websession: - aio_timeout = ClientTimeout(total=timeout) async def _create_session() -> ClientSession: @@ -303,7 +302,9 @@ async def _request( data=data, auth=self._auth, ) - except ClientError as err: # ClientError is an ancestor class of ServerTimeoutError + except ( + ClientError + ) as err: # ClientError is an ancestor class of ServerTimeoutError if retry < 1: LOGGER.warning( "Failed sending %s %s to Plugwise Smile, error: %s", @@ -1014,7 +1015,6 @@ def _get_appliance_data(self, d_id: str) -> DeviceData: if ( appliance := self._appliances.find(f'./appliance[@id="{d_id}"]') ) is not None: - self._appliance_measurements(appliance, data, measurements) self._get_lock_state(appliance, data) @@ -1082,7 +1082,6 @@ def _rank_thermostat( appl_class = appliance_details["dev_class"] appl_d_loc = appliance_details["location"] if loc_id == appl_d_loc and appl_class in thermo_matching: - # Pre-elect new master if thermo_matching[appl_class] > self._thermo_locs[loc_id]["master_prio"]: # Demote former master From 98c1b865c4f57627ed7c98bd06c657588ed6c228 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 25 Feb 2023 14:12:50 +0100 Subject: [PATCH 4/5] Remove unused exception, added builtins --- pyproject.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0adb433c4..c4448a4fe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -167,9 +167,8 @@ expected-line-ending-format = "LF" [tool.pylint.EXCEPTIONS] overgeneral-exceptions = [ - "BaseException", - "Exception", - "HomeAssistantError", + "builtins.BaseException", + "builtins.Exception", ] [tool.pytest.ini_options] From 28e2aaa4b86d6e26bb8deeb68153deff0789783f Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 25 Feb 2023 14:13:16 +0100 Subject: [PATCH 5/5] R1720 no-else-raise --- plugwise/connections/socket.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/plugwise/connections/socket.py b/plugwise/connections/socket.py index f9829b1ff..990d3e0c1 100644 --- a/plugwise/connections/socket.py +++ b/plugwise/connections/socket.py @@ -39,15 +39,14 @@ def _open_connection(self): err, ) raise PortError(err) - else: - self._reader_start("socket_reader_thread") - self._writer_start("socket_writer_thread") - self._is_connected = True - _LOGGER.debug( - "Successfully connected to host '%s' at port %s", - self._socket_host, - str(self._socket_port), - ) + self._reader_start("socket_reader_thread") + self._writer_start("socket_writer_thread") + self._is_connected = True + _LOGGER.debug( + "Successfully connected to host '%s' at port %s", + self._socket_host, + str(self._socket_port), + ) def _close_connection(self): """Close the socket.""" @@ -76,8 +75,7 @@ def _read_data(self): ) self._is_connected = False raise PortError(err) - else: - return socket_data + return socket_data return None def _write_data(self, data):