Skip to content

Commit

Permalink
Remove black from pre-commit (#935)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Aug 29, 2024
1 parent 87cb7c3 commit a3d9b82
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 36 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ jobs:
- run: pylint aioesphomeapi
name: Lint with pylint
if: ${{ matrix.python-version == '3.12' && matrix.extension == 'skip_cython' }}
- run: black --check --diff --color aioesphomeapi tests
name: Check formatting with black
- run: ruff check aioesphomeapi tests
name: Check formatting with ruff
if: ${{ matrix.python-version == '3.12' && matrix.extension == 'skip_cython' }}
- run: mypy aioesphomeapi
name: Check typing with mypy
Expand Down
8 changes: 0 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ repos:
- id: ruff
args: [--fix]
- id: ruff-format
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.1.1
hooks:
- id: black
args:
- --safe
- --quiet
files: ^((aioesphomeapi|tests)/.+)?[^/]+\.py$
- repo: https://github.com/cdce8p/python-typing-update
rev: v0.6.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pylint==3.2.6
black==24.8.0
ruff==0.5.4
flake8==7.1.1
isort==5.13.2
mypy==1.11.2
Expand Down
5 changes: 3 additions & 2 deletions tests/common.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from __future__ import annotations

import asyncio
import time
from collections.abc import Awaitable
from datetime import datetime, timezone
from functools import partial
from typing import Awaitable, Callable
import time
from typing import Callable
from unittest.mock import AsyncMock, MagicMock, patch

from google.protobuf import message
Expand Down
16 changes: 13 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from __future__ import annotations

import asyncio
import socket
from dataclasses import replace
from functools import partial
import socket
from typing import Callable
from unittest.mock import MagicMock, create_autospec, patch

Expand Down Expand Up @@ -181,7 +181,12 @@ async def plaintext_connect_task_no_login_with_expected_name(
connect(conn_with_expected_name, login=False)
)
await connected.wait()
yield conn_with_expected_name, transport, conn_with_expected_name._frame_helper, connect_task
yield (
conn_with_expected_name,
transport,
conn_with_expected_name._frame_helper,
connect_task,
)


@pytest_asyncio.fixture(name="plaintext_connect_task_with_login")
Expand All @@ -201,7 +206,12 @@ async def plaintext_connect_task_with_login(
):
connect_task = asyncio.create_task(connect(conn_with_password, login=True))
await connected.wait()
yield conn_with_password, transport, conn_with_password._frame_helper, connect_task
yield (
conn_with_password,
transport,
conn_with_password._frame_helper,
connect_task,
)


@pytest_asyncio.fixture(name="api_client")
Expand Down
4 changes: 2 additions & 2 deletions tests/test__frame_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
from typing import Any
from unittest.mock import AsyncMock, MagicMock, patch

import pytest
from noise.connection import NoiseConnection # type: ignore[import-untyped]
import pytest

from aioesphomeapi import APIConnection
from aioesphomeapi._frame_helper import APINoiseFrameHelper, APIPlaintextFrameHelper
from aioesphomeapi._frame_helper.noise import ESPHOME_NOISE_BACKEND
from aioesphomeapi._frame_helper.plain_text import (
_cached_varuint_to_bytes as cached_varuint_to_bytes,
_varuint_to_bytes as varuint_to_bytes,
)
from aioesphomeapi._frame_helper.plain_text import _varuint_to_bytes as varuint_to_bytes
from aioesphomeapi.connection import ConnectionState
from aioesphomeapi.core import (
APIConnectionError,
Expand Down
12 changes: 7 additions & 5 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from __future__ import annotations

import asyncio
import logging
import socket
from datetime import timedelta
from functools import partial
import logging
import socket
from typing import Callable, cast
from unittest.mock import AsyncMock, MagicMock, call, create_autospec, patch

import pytest
from google.protobuf import message
import pytest

from aioesphomeapi import APIClient
from aioesphomeapi._frame_helper import APIPlaintextFrameHelper
Expand Down Expand Up @@ -59,7 +59,7 @@
async def test_connect(
plaintext_connect_task_no_login: tuple[
APIConnection, asyncio.Transport, APIPlaintextFrameHelper, asyncio.Task
]
],
) -> None:
"""Test that a plaintext connection works."""
conn, transport, protocol, connect_task = plaintext_connect_task_no_login
Expand Down Expand Up @@ -541,7 +541,9 @@ async def _do_finish_connect(self, *args, **kwargs):
connect_task = asyncio.create_task(connect(conn, login=False))
await connected.wait()

with (pytest.raises(raised_exception),):
with (
pytest.raises(raised_exception),
):
await asyncio.sleep(0)
await connect_task

Expand Down
4 changes: 2 additions & 2 deletions tests/test_host_resolver.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from __future__ import annotations

import asyncio
import socket
from ipaddress import IPv6Address, ip_address
import socket
from unittest.mock import AsyncMock, MagicMock, patch

import pytest
from zeroconf.asyncio import AsyncServiceInfo, AsyncZeroconf

import aioesphomeapi.host_resolver as hr
from aioesphomeapi.core import APIConnectionError, ResolveAPIError
import aioesphomeapi.host_resolver as hr
from aioesphomeapi.zeroconf import ZeroconfManager


Expand Down
9 changes: 6 additions & 3 deletions tests/test_log_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
from functools import partial
from unittest.mock import MagicMock, patch

import pytest
from google.protobuf import message
import pytest

from aioesphomeapi._frame_helper.plain_text import APIPlaintextFrameHelper
from aioesphomeapi.api_pb2 import SubscribeLogsResponse # type: ignore
from aioesphomeapi.api_pb2 import DisconnectRequest, DisconnectResponse
from aioesphomeapi.api_pb2 import (
DisconnectRequest,
DisconnectResponse,
SubscribeLogsResponse, # type: ignore
)
from aioesphomeapi.client import APIClient
from aioesphomeapi.connection import APIConnection
from aioesphomeapi.core import APIConnectionError
Expand Down
12 changes: 4 additions & 8 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from dataclasses import dataclass, field

import pytest
from google.protobuf import message
import pytest

from aioesphomeapi.api_pb2 import (
AlarmControlPanelStateResponse,
Expand Down Expand Up @@ -65,14 +65,10 @@
APIVersion,
BinarySensorInfo,
BinarySensorState,
)
from aioesphomeapi.model import (
BluetoothGATTCharacteristic as BluetoothGATTCharacteristicModel,
)
from aioesphomeapi.model import BluetoothGATTDescriptor as BluetoothGATTDescriptorModel
from aioesphomeapi.model import BluetoothGATTService as BluetoothGATTServiceModel
from aioesphomeapi.model import BluetoothGATTServices as BluetoothGATTServicesModel
from aioesphomeapi.model import (
BluetoothGATTDescriptor as BluetoothGATTDescriptorModel,
BluetoothGATTService as BluetoothGATTServiceModel,
BluetoothGATTServices as BluetoothGATTServicesModel,
BluetoothProxyFeature,
ButtonInfo,
CameraInfo,
Expand Down

0 comments on commit a3d9b82

Please sign in to comment.