Skip to content

Commit

Permalink
Replace isort with ruff (#94302)
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck authored Jun 8, 2023
1 parent ed3d38b commit c3936e6
Show file tree
Hide file tree
Showing 56 changed files with 95 additions and 117 deletions.
41 changes: 0 additions & 41 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -338,44 +338,6 @@ jobs:
shopt -s globstar
pre-commit run --hook-stage manual ruff --files {homeassistant,tests}/components/${{ needs.info.outputs.integrations_glob }}/{*,**/*} --show-diff-on-failure
lint-isort:
name: Check isort
runs-on: ubuntu-22.04
needs:
- info
- pre-commit
steps:
- name: Check out code from GitHub
uses: actions/[email protected]
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/[email protected]
id: python
with:
python-version: ${{ env.DEFAULT_PYTHON }}
check-latest: true
- name: Restore base Python virtual environment
id: cache-venv
uses: actions/cache/[email protected]
with:
path: venv
fail-on-cache-miss: true
key: >-
${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{
needs.info.outputs.pre-commit_cache_key }}
- name: Restore pre-commit environment from cache
id: cache-precommit
uses: actions/cache/[email protected]
with:
path: ${{ env.PRE_COMMIT_CACHE }}
fail-on-cache-miss: true
key: >-
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
needs.info.outputs.pre-commit_cache_key }}
- name: Run isort
run: |
. venv/bin/activate
pre-commit run --hook-stage manual isort --all-files --show-diff-on-failure
lint-other:
name: Check other linters
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -719,7 +681,6 @@ jobs:
- base
- gen-requirements-all
- hassfest
- lint-isort
- lint-other
- lint-ruff
- mypy
Expand Down Expand Up @@ -844,7 +805,6 @@ jobs:
- base
- gen-requirements-all
- hassfest
- lint-isort
- lint-other
- lint-ruff
- mypy
Expand Down Expand Up @@ -952,7 +912,6 @@ jobs:
- base
- gen-requirements-all
- hassfest
- lint-isort
- lint-other
- lint-ruff
- mypy
Expand Down
4 changes: 0 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ repos:
- --quiet-level=2
exclude_types: [csv, json]
exclude: ^tests/fixtures/|homeassistant/generated/
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/auth/providers/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError

from . import AUTH_PROVIDER_SCHEMA, AUTH_PROVIDERS, AuthProvider, LoginFlow
from ..models import Credentials, UserMeta
from . import AUTH_PROVIDER_SCHEMA, AUTH_PROVIDERS, AuthProvider, LoginFlow

CONF_ARGS = "args"
CONF_META = "meta"
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/auth/providers/homeassistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.storage import Store

from . import AUTH_PROVIDER_SCHEMA, AUTH_PROVIDERS, AuthProvider, LoginFlow
from ..models import Credentials, UserMeta
from . import AUTH_PROVIDER_SCHEMA, AUTH_PROVIDERS, AuthProvider, LoginFlow

STORAGE_VERSION = 1
STORAGE_KEY = "auth_provider.homeassistant"
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/auth/providers/insecure_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError

from . import AUTH_PROVIDER_SCHEMA, AUTH_PROVIDERS, AuthProvider, LoginFlow
from ..models import Credentials, UserMeta
from . import AUTH_PROVIDER_SCHEMA, AUTH_PROVIDERS, AuthProvider, LoginFlow

USER_SCHEMA = vol.Schema(
{
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/auth/providers/legacy_api_password.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
from homeassistant.exceptions import HomeAssistantError
import homeassistant.helpers.config_validation as cv

from . import AUTH_PROVIDER_SCHEMA, AUTH_PROVIDERS, AuthProvider, LoginFlow
from ..models import Credentials, UserMeta
from . import AUTH_PROVIDER_SCHEMA, AUTH_PROVIDERS, AuthProvider, LoginFlow

AUTH_PROVIDER_TYPE = "legacy_api_password"
CONF_API_PASSWORD = "api_password"
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/auth/providers/trusted_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
from homeassistant.exceptions import HomeAssistantError
import homeassistant.helpers.config_validation as cv

from . import AUTH_PROVIDER_SCHEMA, AUTH_PROVIDERS, AuthProvider, LoginFlow
from .. import InvalidAuthError
from ..models import Credentials, RefreshToken, UserMeta
from . import AUTH_PROVIDER_SCHEMA, AUTH_PROVIDERS, AuthProvider, LoginFlow

IPAddress = IPv4Address | IPv6Address
IPNetwork = IPv4Network | IPv6Network
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/ads/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, StateType

from .. import ads
from . import (
ADS_TYPEMAP,
CONF_ADS_FACTOR,
Expand All @@ -18,7 +19,6 @@
STATE_KEY_STATE,
AdsEntity,
)
from .. import ads

DEFAULT_NAME = "ADS sensor"
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/color_extractor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import io
import logging

from PIL import UnidentifiedImageError
import aiohttp
import async_timeout
from colorthief import ColorThief
from PIL import UnidentifiedImageError
import voluptuous as vol

from homeassistant.components.light import (
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/generic/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import logging
from typing import Any

import PIL
from aiohttp import web
from async_timeout import timeout
from httpx import HTTPStatusError, RequestError, TimeoutException
import PIL
import voluptuous as vol
import yarl

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/google_assistant/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
DEFAULT_EXPOSE_BY_DEFAULT,
DEFAULT_EXPOSED_DOMAINS,
DOMAIN,
EVENT_QUERY_RECEIVED, # noqa: F401
SERVICE_REQUEST_SYNC,
SOURCE_CLOUD,
)
from .const import EVENT_QUERY_RECEIVED # noqa: F401
from .http import GoogleAssistantView, GoogleConfig

from .const import EVENT_COMMAND_RECEIVED, EVENT_SYNC_RECEIVED # noqa: F401, isort:skip
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/huawei_lte/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

from huawei_lte_api.Client import Client
from huawei_lte_api.Connection import Connection
from huawei_lte_api.Session import GetResponseType
from huawei_lte_api.exceptions import (
LoginErrorPasswordWrongException,
LoginErrorUsernamePasswordOverrunException,
LoginErrorUsernamePasswordWrongException,
LoginErrorUsernameWrongException,
ResponseErrorException,
)
from huawei_lte_api.Session import GetResponseType
from requests.exceptions import Timeout
from url_normalize import url_normalize
import voluptuous as vol
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/image_upload/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import shutil
from typing import Any

from PIL import Image, ImageOps, UnidentifiedImageError
from aiohttp import hdrs, web
from aiohttp.web_request import FileField
from PIL import Image, ImageOps, UnidentifiedImageError
import voluptuous as vol

from homeassistant.components.http.static import CACHE_HEADERS
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/logger/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
from .const import (
ATTR_LEVEL,
DOMAIN,
EVENT_LOGGING_CHANGED, # noqa: F401
LOGGER_DEFAULT,
LOGGER_FILTERS,
LOGGER_LOGS,
LOGSEVERITY,
SERVICE_SET_DEFAULT_LEVEL,
SERVICE_SET_LEVEL,
)
from .const import EVENT_LOGGING_CHANGED # noqa: F401
from .helpers import (
LoggerDomainConfig,
LoggerSettings,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/mqtt/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

from homeassistant.core import HomeAssistant

from . import debug_info
from .. import mqtt
from . import debug_info
from .const import DEFAULT_QOS
from .models import MessageCallbackType

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/progettihwsw/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Automation manager for boards manufactured by ProgettiHWSW Italy."""

from ProgettiHWSW.ProgettiHWSWAPI import ProgettiHWSWAPI
from ProgettiHWSW.input import Input
from ProgettiHWSW.ProgettiHWSWAPI import ProgettiHWSWAPI
from ProgettiHWSW.relay import Relay

from homeassistant.config_entries import ConfigEntry
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/progettihwsw/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from datetime import timedelta
import logging

from ProgettiHWSW.input import Input
import async_timeout
from ProgettiHWSW.input import Input

from homeassistant.components.binary_sensor import BinarySensorEntity
from homeassistant.config_entries import ConfigEntry
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/progettihwsw/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import logging
from typing import Any

from ProgettiHWSW.relay import Relay
import async_timeout
from ProgettiHWSW.relay import Relay

from homeassistant.components.switch import SwitchEntity
from homeassistant.config_entries import ConfigEntry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
from homeassistant.core import Event
from homeassistant.util.json import JSON_ENCODE_EXCEPTIONS

from . import BaseLRUTableManager
from ..const import SQLITE_MAX_BIND_VARS
from ..db_schema import EventData
from ..queries import get_shared_event_datas
from ..util import chunked, execute_stmt_lambda_element
from . import BaseLRUTableManager

if TYPE_CHECKING:
from ..core import Recorder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

from homeassistant.core import Event

from . import BaseLRUTableManager
from ..const import SQLITE_MAX_BIND_VARS
from ..db_schema import EventTypes
from ..queries import find_event_type_ids
from ..tasks import RefreshEventTypesTask
from ..util import chunked, execute_stmt_lambda_element
from . import BaseLRUTableManager

if TYPE_CHECKING:
from ..core import Recorder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
from homeassistant.helpers.entity import entity_sources
from homeassistant.util.json import JSON_ENCODE_EXCEPTIONS

from . import BaseLRUTableManager
from ..const import SQLITE_MAX_BIND_VARS
from ..db_schema import StateAttributes
from ..queries import get_shared_attributes
from ..util import chunked, execute_stmt_lambda_element
from . import BaseLRUTableManager

if TYPE_CHECKING:
from ..core import Recorder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

from homeassistant.core import Event

from . import BaseLRUTableManager
from ..const import SQLITE_MAX_BIND_VARS
from ..db_schema import StatesMeta
from ..queries import find_all_states_metadata_ids, find_states_metadata_ids
from ..util import chunked, execute_stmt_lambda_element
from . import BaseLRUTableManager

if TYPE_CHECKING:
from ..core import Recorder
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/remote_rpi_gpio/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType

from .. import remote_rpi_gpio
from . import (
CONF_BOUNCETIME,
CONF_INVERT_LOGIC,
Expand All @@ -19,7 +20,6 @@
DEFAULT_INVERT_LOGIC,
DEFAULT_PULL_MODE,
)
from .. import remote_rpi_gpio

CONF_PORTS = "ports"

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/remote_rpi_gpio/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType

from . import CONF_INVERT_LOGIC, DEFAULT_INVERT_LOGIC
from .. import remote_rpi_gpio
from . import CONF_INVERT_LOGIC, DEFAULT_INVERT_LOGIC

CONF_PORTS = "ports"

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/rfxtrx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import logging
from typing import Any, NamedTuple, cast

import RFXtrx as rfxtrxmod
import async_timeout
import RFXtrx as rfxtrxmod
import voluptuous as vol

from homeassistant.config_entries import ConfigEntry
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/rfxtrx/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import os
from typing import Any, TypedDict, cast

import RFXtrx as rfxtrxmod
from async_timeout import timeout
import RFXtrx as rfxtrxmod
import serial
import serial.tools.list_ports
import voluptuous as vol
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/tellduslive/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import TelldusLiveClient
from .. import tellduslive
from . import TelldusLiveClient
from .entry import TelldusLiveEntity


Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/tensorflow/image_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import sys
import time

from PIL import Image, ImageDraw, UnidentifiedImageError
import numpy as np
from PIL import Image, ImageDraw, UnidentifiedImageError
import tensorflow as tf # pylint: disable=import-error
import voluptuous as vol

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/w800rf32/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Support for w800rf32 devices."""
import logging

import W800rf32 as w800
import voluptuous as vol
import W800rf32 as w800

from homeassistant.const import (
CONF_DEVICE,
Expand Down
Loading

0 comments on commit c3936e6

Please sign in to comment.