From 971716d65b09f4ef3bd17b26baa545165bc0ba7f Mon Sep 17 00:00:00 2001 From: Jakob Schlyter Date: Fri, 3 May 2024 18:28:04 +0200 Subject: [PATCH 1/5] bump --- .github/workflows/hassfest.yaml | 2 +- .github/workflows/test.yml | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/hassfest.yaml b/.github/workflows/hassfest.yaml index 18c7d19..8fe5df7 100644 --- a/.github/workflows/hassfest.yaml +++ b/.github/workflows/hassfest.yaml @@ -10,5 +10,5 @@ jobs: validate: runs-on: "ubuntu-latest" steps: - - uses: "actions/checkout@v2" + - uses: "actions/checkout@v4" - uses: home-assistant/actions/hassfest@master diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bd1f54f..b39b5a9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,13 +8,11 @@ jobs: strategy: matrix: python-version: - - "3.9" - - "3.10" - - "3.11" + - "3.12" steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Get full python version From 558f6f4e91d2db49c47c153ed84527080a27d225 Mon Sep 17 00:00:00 2001 From: Jakob Schlyter Date: Fri, 3 May 2024 18:30:10 +0200 Subject: [PATCH 2/5] bump --- .github/workflows/test.yml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b39b5a9..6d5b3fa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,18 +12,9 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - name: Get full python version - id: full-python-version - run: | - echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info[:3]))") - - name: Set up cache - uses: actions/cache@v2 - with: - path: .venv - key: ${{ runner.os }}-venv-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }} - name: Build venv run: python -m venv .venv - name: Install dependencies From 788ef1c480b44d9d90c73f2617763ccabe35c279 Mon Sep 17 00:00:00 2001 From: Jakob Schlyter Date: Fri, 3 May 2024 18:31:37 +0200 Subject: [PATCH 3/5] reformat --- custom_components/chargeamps/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/custom_components/chargeamps/__init__.py b/custom_components/chargeamps/__init__.py index 68221ad..0ba01c1 100644 --- a/custom_components/chargeamps/__init__.py +++ b/custom_components/chargeamps/__init__.py @@ -323,9 +323,9 @@ async def _update_data(self, charge_point_id, force: bool = False): charge_point_id, total_energy, ) - self.hass.data[DOMAIN_DATA]["chargepoint_total_energy"][ - charge_point_id - ] = round(total_energy, 2) + self.hass.data[DOMAIN_DATA]["chargepoint_total_energy"][charge_point_id] = ( + round(total_energy, 2) + ) settings = await self.client.get_chargepoint_settings(charge_point_id) self.hass.data[DOMAIN_DATA]["chargepoint_settings"][ charge_point_id From a275044c74f5cc982ada9af926d6503a51f06430 Mon Sep 17 00:00:00 2001 From: Jakob Schlyter Date: Fri, 3 May 2024 18:45:11 +0200 Subject: [PATCH 4/5] use ruff --- .github/workflows/ruff.yml | 10 +++++++++ .github/workflows/test.yml | 27 ------------------------ custom_components/chargeamps/__init__.py | 12 +++++------ custom_components/chargeamps/light.py | 4 +--- custom_components/chargeamps/sensor.py | 4 +--- custom_components/chargeamps/switch.py | 4 +--- pyproject.toml | 22 +++++++++++++++++++ 7 files changed, 41 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/ruff.yml delete mode 100644 .github/workflows/test.yml create mode 100644 pyproject.toml diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml new file mode 100644 index 0000000..3ab0239 --- /dev/null +++ b/.github/workflows/ruff.yml @@ -0,0 +1,10 @@ +name: Ruff + +on: [ push, pull_request ] + +jobs: + ruff: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: chartboost/ruff-action@v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 6d5b3fa..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Tests - -on: [push, pull_request] - -jobs: - test: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: - - "3.12" - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Build venv - run: python -m venv .venv - - name: Install dependencies - run: .venv/bin/pip3 install isort black pylama - - name: isort - run: .venv/bin/isort --check custom_components/chargeamps - - name: black - run: .venv/bin/black --check custom_components/chargeamps - - name: pylama - run: .venv/bin/pylama custom_components/chargeamps diff --git a/custom_components/chargeamps/__init__.py b/custom_components/chargeamps/__init__.py index 0ba01c1..098ea7c 100644 --- a/custom_components/chargeamps/__init__.py +++ b/custom_components/chargeamps/__init__.py @@ -309,9 +309,9 @@ async def _update_data(self, charge_point_id, force: bool = False): charge_point_id, connector_status.connector_id ) ) - self.hass.data[DOMAIN_DATA]["connector_settings"][ - key - ] = connector_settings + self.hass.data[DOMAIN_DATA]["connector_settings"][key] = ( + connector_settings + ) total_energy = sum( [ v.total_consumption_kwh @@ -327,9 +327,9 @@ async def _update_data(self, charge_point_id, force: bool = False): round(total_energy, 2) ) settings = await self.client.get_chargepoint_settings(charge_point_id) - self.hass.data[DOMAIN_DATA]["chargepoint_settings"][ - charge_point_id - ] = settings + self.hass.data[DOMAIN_DATA]["chargepoint_settings"][charge_point_id] = ( + settings + ) except Exception as error: # pylint: disable=broad-except _LOGGER.error("Could not update data - %s", error) diff --git a/custom_components/chargeamps/light.py b/custom_components/chargeamps/light.py index 6c090bb..c2e733b 100644 --- a/custom_components/chargeamps/light.py +++ b/custom_components/chargeamps/light.py @@ -10,9 +10,7 @@ _LOGGER = logging.getLogger(__name__) -async def async_setup_platform( - hass, config, async_add_entities, discovery_info=None -): # pylint: disable=unused-argument +async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): # pylint: disable=unused-argument """Setup light platform.""" lights = [] handler = hass.data[DOMAIN_DATA]["handler"] diff --git a/custom_components/chargeamps/sensor.py b/custom_components/chargeamps/sensor.py index 642b6b9..dfcdc1b 100644 --- a/custom_components/chargeamps/sensor.py +++ b/custom_components/chargeamps/sensor.py @@ -15,9 +15,7 @@ _LOGGER = logging.getLogger(__name__) -async def async_setup_platform( - hass, config, async_add_entities, discovery_info=None -): # pylint: disable=unused-argument +async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): # pylint: disable=unused-argument """Setup sensor platform.""" sensors = [] handler = hass.data[DOMAIN_DATA]["handler"] diff --git a/custom_components/chargeamps/switch.py b/custom_components/chargeamps/switch.py index 4d12ed8..cfbf237 100644 --- a/custom_components/chargeamps/switch.py +++ b/custom_components/chargeamps/switch.py @@ -10,9 +10,7 @@ _LOGGER = logging.getLogger(__name__) -async def async_setup_platform( - hass, config, async_add_entities, discovery_info=None -): # pylint: disable=unused-argument +async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): # pylint: disable=unused-argument """Setup switch platform.""" switches = [] handler = hass.data[DOMAIN_DATA]["handler"] diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..65fa9f8 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,22 @@ +[tool.isort] +profile = "black" + +[tool.ruff] +line-length = 132 + +[tool.ruff.lint] +select = [ + # pycodestyle + "E", + # Pyflakes + "F", + # pyupgrade + "UP", + # flake8-bugbear + "B", + # flake8-simplify + "SIM", + # isort + "I", +] +ignore = ["I001"] From 521259e81a2fe32bd8c2742d14e3d7da4b0571c1 Mon Sep 17 00:00:00 2001 From: Jakob Schlyter Date: Fri, 3 May 2024 18:45:44 +0200 Subject: [PATCH 5/5] version --- .github/workflows/ruff.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index 3ab0239..5b8f29e 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -6,5 +6,5 @@ jobs: ruff: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v4 - uses: chartboost/ruff-action@v1