From b8a75fee1a6537bc9c46dd5cc2d47f6f398f63e7 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 8 Dec 2024 23:56:32 +0100 Subject: [PATCH] Update linters/formatters/precommit to match other projects --- .github/workflows/linting.yaml | 33 ++++----------------------------- .pre-commit-config.yaml | 17 ++++++----------- pyproject.toml | 7 +++++-- src/demetriek/__init__.py | 3 ++- src/demetriek/cloud.py | 1 + src/demetriek/device.py | 1 + src/demetriek/models.py | 1 + tests/__init__.py | 1 + tests/test_apps.py | 1 + tests/test_audio.py | 1 + tests/test_bluetooth.py | 1 + tests/test_cloud.py | 1 + tests/test_device.py | 1 + tests/test_display.py | 1 + tests/test_lametric.py | 1 + tests/test_wifi.py | 1 + 16 files changed, 29 insertions(+), 43 deletions(-) diff --git a/.github/workflows/linting.yaml b/.github/workflows/linting.yaml index d093faf8..c84f76b2 100644 --- a/.github/workflows/linting.yaml +++ b/.github/workflows/linting.yaml @@ -54,31 +54,10 @@ jobs: poetry config virtualenvs.in-project true - name: ๐Ÿ— Install Python dependencies run: poetry install --no-interaction - - name: ๐Ÿš€ Run Ruff - run: poetry run ruff check . - - black: - name: black - runs-on: ubuntu-latest - steps: - - name: โคต๏ธ Check out code from GitHub - uses: actions/checkout@v4.2.2 - - name: ๐Ÿ— Set up Poetry - run: pipx install poetry - - name: ๐Ÿ— Set up Python ${{ env.DEFAULT_PYTHON }} - id: python - uses: actions/setup-python@v5.3.0 - with: - python-version: ${{ env.DEFAULT_PYTHON }} - cache: "poetry" - - name: ๐Ÿ— Install workflow dependencies - run: | - poetry config virtualenvs.create true - poetry config virtualenvs.in-project true - - name: ๐Ÿ— Install Python dependencies - run: poetry install --no-interaction - - name: ๐Ÿš€ Run black on docs - run: poetry run blacken-docs + - name: ๐Ÿš€ Run ruff linter + run: poetry run ruff check --output-format=github . + - name: ๐Ÿš€ Run ruff formatter + run: poetry run ruff format --check . pre-commit-hooks: name: pre-commit-hooks @@ -116,10 +95,6 @@ jobs: run: poetry run pre-commit run check-symlinks --all-files - name: ๐Ÿš€ Check TOML files run: poetry run pre-commit run check-toml --all-files - - name: ๐Ÿš€ Check XML files - run: poetry run pre-commit run check-xml --all-files - - name: ๐Ÿš€ Check YAML files - run: poetry run pre-commit run check-yaml --all-files - name: ๐Ÿš€ Check YAML files run: poetry run pre-commit run check-yaml --all-files - name: ๐Ÿš€ Detect Private Keys diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2728c6af..709da1da 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,25 +2,20 @@ repos: - repo: local hooks: - - id: ruff - name: ๐Ÿถ Ruff + - id: ruff-check + name: ๐Ÿถ Ruff Linter language: system types: [python] entry: poetry run ruff check --fix require_serial: true stages: [commit, push, manual] - - id: black - name: โ˜•๏ธ Format using black + - id: ruff-format + name: ๐Ÿถ Ruff Formatter language: system types: [python] - entry: poetry run black - require_serial: true - - id: blacken-docs - name: โ˜•๏ธ Format documentation examples using black - language: system - files: '\.(rst|md|markdown|py|tex)$' - entry: poetry run blacken-docs + entry: poetry run ruff format require_serial: true + stages: [commit, push, manual] - id: check-ast name: ๐Ÿ Check Python AST language: system diff --git a/pyproject.toml b/pyproject.toml index bfc716f9..5ad3604b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -122,13 +122,16 @@ asyncio_mode = "auto" [tool.ruff.lint] ignore = [ - "ANN101", # Self... explanatory - "ANN102", # cls... just as annoying as ANN101 "ANN401", # Opinioated warning on disallowing dynamically typed expressions "D203", # Conflicts with other rules "D213", # Conflicts with other rules "D417", # False positives in some occasions "PLR2004", # Just annoying, not really useful + + + # Conflicts with the Ruff formatter + "COM812", + "ISC001", ] select = ["ALL"] diff --git a/src/demetriek/__init__.py b/src/demetriek/__init__.py index 313dec9e..211a3304 100644 --- a/src/demetriek/__init__.py +++ b/src/demetriek/__init__.py @@ -1,4 +1,5 @@ """Asynchronous Python client for LaMetric TIME devices.""" + from .cloud import LaMetricCloud from .const import ( AlarmSound, @@ -52,8 +53,8 @@ "DisplayType", "Goal", "GoalData", - "LaMetricCloud", "LaMetricAuthenticationError", + "LaMetricCloud", "LaMetricConnectionError", "LaMetricConnectionTimeoutError", "LaMetricDevice", diff --git a/src/demetriek/cloud.py b/src/demetriek/cloud.py index 06da9b1d..314d93dc 100644 --- a/src/demetriek/cloud.py +++ b/src/demetriek/cloud.py @@ -1,4 +1,5 @@ """Asynchronous Python client for LaMetric TIME devices.""" + from __future__ import annotations import asyncio diff --git a/src/demetriek/device.py b/src/demetriek/device.py index 64d71d30..96ccd405 100644 --- a/src/demetriek/device.py +++ b/src/demetriek/device.py @@ -1,4 +1,5 @@ """Asynchronous Python client for LaMetric TIME devices.""" + from __future__ import annotations import asyncio diff --git a/src/demetriek/models.py b/src/demetriek/models.py index 75026f92..e0358efb 100644 --- a/src/demetriek/models.py +++ b/src/demetriek/models.py @@ -1,4 +1,5 @@ """Models for LaMetric.""" + from __future__ import annotations from datetime import datetime diff --git a/tests/__init__.py b/tests/__init__.py index 7b1589f1..bf2c61b4 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,4 +1,5 @@ """Asynchronous Python client for LaMetric TIME devices.""" + from pathlib import Path diff --git a/tests/test_apps.py b/tests/test_apps.py index 0fd0ed62..7b37f1c7 100644 --- a/tests/test_apps.py +++ b/tests/test_apps.py @@ -1,4 +1,5 @@ """Asynchronous Python client for LaMetric TIME devices.""" + # pylint: disable=protected-access import aiohttp from aresponses import ResponsesMockServer diff --git a/tests/test_audio.py b/tests/test_audio.py index 024f59dd..795b9291 100644 --- a/tests/test_audio.py +++ b/tests/test_audio.py @@ -1,4 +1,5 @@ """Asynchronous Python client for LaMetric TIME devices.""" + # pylint: disable=protected-access import aiohttp from aresponses import Response, ResponsesMockServer diff --git a/tests/test_bluetooth.py b/tests/test_bluetooth.py index 92e22cf1..1bc86535 100644 --- a/tests/test_bluetooth.py +++ b/tests/test_bluetooth.py @@ -1,4 +1,5 @@ """Asynchronous Python client for LaMetric TIME devices.""" + # pylint: disable=protected-access import aiohttp from aresponses import Response, ResponsesMockServer diff --git a/tests/test_cloud.py b/tests/test_cloud.py index f085dfa8..359ed876 100644 --- a/tests/test_cloud.py +++ b/tests/test_cloud.py @@ -1,4 +1,5 @@ """Asynchronous Python client for LaMetric TIME devices.""" + # pylint: disable=protected-access import asyncio from datetime import datetime, timezone diff --git a/tests/test_device.py b/tests/test_device.py index 9fc94066..1553fff1 100644 --- a/tests/test_device.py +++ b/tests/test_device.py @@ -1,4 +1,5 @@ """Asynchronous Python client for LaMetric TIME devices.""" + # pylint: disable=protected-access from ipaddress import IPv4Address diff --git a/tests/test_display.py b/tests/test_display.py index 92d0c795..ba2bd73e 100644 --- a/tests/test_display.py +++ b/tests/test_display.py @@ -1,4 +1,5 @@ """Asynchronous Python client for LaMetric TIME devices.""" + # pylint: disable=protected-access import aiohttp from aresponses import Response, ResponsesMockServer diff --git a/tests/test_lametric.py b/tests/test_lametric.py index 8548ecc3..39ff2aee 100644 --- a/tests/test_lametric.py +++ b/tests/test_lametric.py @@ -1,4 +1,5 @@ """Asynchronous Python client for LaMetric TIME devices.""" + # pylint: disable=protected-access import asyncio diff --git a/tests/test_wifi.py b/tests/test_wifi.py index da8a278e..f02a3ab9 100644 --- a/tests/test_wifi.py +++ b/tests/test_wifi.py @@ -1,4 +1,5 @@ """Asynchronous Python client for LaMetric TIME devices.""" + # pylint: disable=protected-access from ipaddress import IPv4Address