Skip to content

Commit

Permalink
chore: Move from reorder-imports to isort
Browse files Browse the repository at this point in the history
- refer psf/black#4175
- issue identified by jaymunro #114
- bumped pre-commit-hooks repo to v4.5.0
  • Loading branch information
agittins committed Feb 28, 2024
1 parent df82d92 commit dfcd49e
Show file tree
Hide file tree
Showing 17 changed files with 55 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Install Python modules
run: |
pip install --constraint=.github/workflows/constraints.txt pre-commit black flake8 reorder-python-imports
pip install --constraint=.github/workflows/constraints.txt pre-commit black flake8 isort
- name: Run pre-commit on all files
run: |
Expand Down
4 changes: 4 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[settings]
add_imports=from __future__ import annotations
force_single_line=true
profile=black
12 changes: 5 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-yaml
Expand All @@ -20,12 +20,10 @@ repos:
language: system
types: [python]
require_serial: true
- id: reorder-python-imports
name: Reorder python imports
entry: reorder-python-imports
language: system
types: [python]
args: [--application-directories=custom_components]
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.2
hooks:
Expand Down
2 changes: 2 additions & 0 deletions custom_components/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
"""Dummy init so that pytest works."""

from __future__ import annotations
4 changes: 2 additions & 2 deletions custom_components/bermuda/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@

import voluptuous as vol
from homeassistant.components import bluetooth
from homeassistant.components.bluetooth import MONOTONIC_TIME
from homeassistant.components.bluetooth import BluetoothChange
from homeassistant.components.bluetooth import BluetoothScannerDevice
from homeassistant.components.bluetooth import BluetoothServiceInfoBleak
from homeassistant.components.bluetooth import MONOTONIC_TIME
from homeassistant.components.bluetooth.active_update_coordinator import (
PassiveBluetoothDataUpdateCoordinator,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import STATE_HOME
from homeassistant.const import STATE_NOT_HOME
from homeassistant.const import STATE_UNAVAILABLE
from homeassistant.core import callback
from homeassistant.core import Config
from homeassistant.core import HomeAssistant
from homeassistant.core import SupportsResponse
from homeassistant.core import callback
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import area_registry
from homeassistant.helpers import config_validation as cv
Expand Down
2 changes: 2 additions & 0 deletions custom_components/bermuda/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Binary sensor platform for Bermuda BLE Trilateration."""
from __future__ import annotations

from homeassistant.components.binary_sensor import BinarySensorEntity

from .const import BINARY_SENSOR
Expand Down
2 changes: 2 additions & 0 deletions custom_components/bermuda/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Adds config flow for Bermuda BLE Trilateration."""
from __future__ import annotations

import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import bluetooth
Expand Down
2 changes: 2 additions & 0 deletions custom_components/bermuda/const.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Constants for Bermuda BLE Trilateration."""
# Base component constants
from __future__ import annotations

NAME = "Bermuda BLE Trilateration"
DOMAIN = "bermuda"
DOMAIN_DATA = f"{DOMAIN}_data"
Expand Down
4 changes: 3 additions & 1 deletion custom_components/bermuda/sensor.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
"""Sensor platform for Bermuda BLE Trilateration."""
from __future__ import annotations

from collections.abc import Mapping
from typing import Any

from homeassistant import config_entries
from homeassistant.components.sensor import SensorDeviceClass
from homeassistant.components.sensor import SensorStateClass
from homeassistant.const import UnitOfLength
from homeassistant.core import callback
from homeassistant.core import HomeAssistant
from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback

Expand Down
2 changes: 2 additions & 0 deletions custom_components/bermuda/switch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Switch platform for Bermuda BLE Trilateration."""
from __future__ import annotations

from homeassistant.components.switch import SwitchEntity

from .const import DEFAULT_NAME
Expand Down
2 changes: 1 addition & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ pytest-asyncio
pytest-homeassistant-custom-component
#==0.13.50
pre-commit
reorder-python-imports
isort
pyserial-asyncio==0.6
pyserial==3.5
2 changes: 2 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
"""Tests for Bermuda BLE Trilateration integration."""

from __future__ import annotations
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Global fixtures for Bermuda BLE Trilateration integration."""
from __future__ import annotations

from unittest.mock import patch

import pytest
Expand Down
2 changes: 2 additions & 0 deletions tests/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
# CONF_USERNAME,
# )
# MOCK_CONFIG = {CONF_USERNAME: "test_username", CONF_PASSWORD: "test_password"}
from __future__ import annotations

MOCK_CONFIG = {}
23 changes: 8 additions & 15 deletions tests/test_config_flow.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
"""Test Bermuda BLE Trilateration config flow."""
from __future__ import annotations

from unittest.mock import patch

import pytest
from custom_components.bermuda.const import (
BINARY_SENSOR,
)
from custom_components.bermuda.const import (
DOMAIN,
)
from custom_components.bermuda.const import (
PLATFORMS,
)
from custom_components.bermuda.const import (
SENSOR,
)
from custom_components.bermuda.const import (
SWITCH,
)
from homeassistant import config_entries
from homeassistant import data_entry_flow
from pytest_homeassistant_custom_component.common import MockConfigEntry

from custom_components.bermuda.const import BINARY_SENSOR
from custom_components.bermuda.const import DOMAIN
from custom_components.bermuda.const import PLATFORMS
from custom_components.bermuda.const import SENSOR
from custom_components.bermuda.const import SWITCH

from .const import MOCK_CONFIG


Expand Down
23 changes: 8 additions & 15 deletions tests/test_init.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
"""Test Bermuda BLE Trilateration setup process."""
from __future__ import annotations

import pytest
from custom_components.bermuda import (
async_reload_entry,
)
from custom_components.bermuda import (
async_setup_entry,
)
from custom_components.bermuda import (
async_unload_entry,
)
from custom_components.bermuda import (
BermudaDataUpdateCoordinator,
)
from custom_components.bermuda.const import (
DOMAIN,
)
from homeassistant.exceptions import ConfigEntryNotReady
from pytest_homeassistant_custom_component.common import MockConfigEntry

from custom_components.bermuda import BermudaDataUpdateCoordinator
from custom_components.bermuda import async_reload_entry
from custom_components.bermuda import async_setup_entry
from custom_components.bermuda import async_unload_entry
from custom_components.bermuda.const import DOMAIN

from .const import MOCK_CONFIG

# from pytest_homeassistant_custom_component.common import AsyncMock
Expand Down
19 changes: 7 additions & 12 deletions tests/test_switch.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
"""Test Bermuda BLE Trilateration switch."""
from __future__ import annotations

from unittest.mock import call
from unittest.mock import patch

from custom_components.bermuda import (
async_setup_entry,
)
from custom_components.bermuda.const import (
DEFAULT_NAME,
)
from custom_components.bermuda.const import (
DOMAIN,
)
from custom_components.bermuda.const import (
SWITCH,
)
from homeassistant.components.switch import SERVICE_TURN_OFF
from homeassistant.components.switch import SERVICE_TURN_ON
from homeassistant.const import ATTR_ENTITY_ID
from pytest_homeassistant_custom_component.common import MockConfigEntry

from custom_components.bermuda import async_setup_entry
from custom_components.bermuda.const import DEFAULT_NAME
from custom_components.bermuda.const import DOMAIN
from custom_components.bermuda.const import SWITCH

from .const import MOCK_CONFIG


Expand Down

0 comments on commit dfcd49e

Please sign in to comment.