Skip to content

Commit

Permalink
Upgrade isort to 5.4.2 (home-assistant#37939)
Browse files Browse the repository at this point in the history
  • Loading branch information
scop authored Aug 29, 2020
1 parent 1bf2c4d commit 6ae9399
Show file tree
Hide file tree
Showing 23 changed files with 38 additions and 41 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ repos:
- --format=custom
- --configfile=tests/bandit.yaml
files: ^(homeassistant|script|tests)/.+\.py$
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.21
- repo: https://github.com/timothycrosley/isort
rev: 5.4.2
hooks:
- id: isort
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def closefds_osx(min_fd: int, max_fd: int) -> None:
get rid of.
"""
# pylint: disable=import-outside-toplevel
from fcntl import fcntl, F_GETFD, F_SETFD, FD_CLOEXEC
from fcntl import F_GETFD, F_SETFD, FD_CLOEXEC, fcntl

for _fd in range(min_fd, max_fd):
try:
Expand Down
6 changes: 4 additions & 2 deletions homeassistant/auth/permissions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

if TYPE_CHECKING:
# pylint: disable=unused-import
from homeassistant.helpers import entity_registry as ent_reg # noqa: F401
from homeassistant.helpers import device_registry as dev_reg # noqa: F401
from homeassistant.helpers import ( # noqa: F401
device_registry as dev_reg,
entity_registry as ent_reg,
)


@attr.s(slots=True)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/homekit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,14 +606,14 @@ def _start(self, bridged_states):
type_cameras,
type_covers,
type_fans,
type_humidifiers,
type_lights,
type_locks,
type_media_players,
type_security_systems,
type_sensors,
type_switches,
type_thermostats,
type_humidifiers,
)

for state in bridged_states:
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/huawei_lte/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
)
from homeassistant.core import callback

# see https://github.com/PyCQA/pylint/issues/3202 about the DOMAIN's pylint issue
from .const import CONNECTION_TIMEOUT, DEFAULT_DEVICE_NAME, DEFAULT_NOTIFY_SERVICE_NAME

# see https://github.com/PyCQA/pylint/issues/3202 about the DOMAIN's pylint issue
from .const import DOMAIN # pylint: disable=unused-import

_LOGGER = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/switcher_kis/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

# pylint: disable=ungrouped-imports
if TYPE_CHECKING:
from aioswitcher.devices import SwitcherV2Device
from aioswitcher.api.messages import SwitcherV2ControlResponseMSG
from aioswitcher.devices import SwitcherV2Device


_LOGGER = getLogger(__name__)
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 @@ -125,8 +125,8 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
# (The model_dir is created during the manual setup process. See integration docs.)

# pylint: disable=import-outside-toplevel
from object_detection.utils import config_util, label_map_util
from object_detection.builders import model_builder
from object_detection.utils import config_util, label_map_util
except ImportError:
_LOGGER.error(
"No TensorFlow Object Detection library found! Install or compile "
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/zha/core/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
ZigpyZdoType = zigpy.zdo.ZDO

if TYPE_CHECKING:
import homeassistant.components.zha.core.channels
import homeassistant.components.zha.core.channels as channels
import homeassistant.components.zha.core.channels.base as base_channels
import homeassistant.components.zha.core.device
import homeassistant.components.zha.core.gateway
import homeassistant.components.zha.core.group
import homeassistant.components.zha.entity
import homeassistant.components.zha.core.channels

ChannelType = base_channels.ZigbeeChannel
ChannelsType = channels.Channels
Expand Down
9 changes: 5 additions & 4 deletions homeassistant/components/zwave/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,13 @@ async def async_setup_entry(hass, config_entry):
Will automatically load components to support devices found on the network.
"""
from pydispatch import dispatcher

# pylint: disable=import-error
from openzwave.option import ZWaveOption
from openzwave.network import ZWaveNetwork
from openzwave.group import ZWaveGroup
from openzwave.network import ZWaveNetwork
from openzwave.option import ZWaveOption

# pylint: enable=import-error
from pydispatch import dispatcher

# Merge config entry and yaml config
config = config_entry.data
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/zwave/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ async def async_step_user(self, user_input=None):

if user_input is not None:
# Check if USB path is valid
from openzwave.option import ZWaveOption
from openzwave.object import ZWaveException
from openzwave.option import ZWaveOption

try:
from functools import partial
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@
# Typing imports that create a circular dependency
if TYPE_CHECKING:
from homeassistant.auth import AuthManager
from homeassistant.config_entries import ConfigEntries
from homeassistant.components.http import HomeAssistantHTTP
from homeassistant.config_entries import ConfigEntries


block_async_io.enable()
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_pre_commit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ black==20.8b1
codespell==1.17.1
flake8-docstrings==1.5.0
flake8==3.8.3
isort==4.3.21
isort==5.4.2
pydocstyle==5.0.2
pyupgrade==2.7.2
yamllint==1.24.2
3 changes: 1 addition & 2 deletions script/gen_requirements_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import re
import sys

from script.hassfest.model import Integration

from homeassistant.util.yaml.loader import load_yaml
from script.hassfest.model import Integration

COMMENT_REQUIREMENTS = (
"Adafruit_BBIO",
Expand Down
2 changes: 1 addition & 1 deletion script/hassfest/translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import re
from typing import Dict

from script.translations import upload
import voluptuous as vol
from voluptuous.humanize import humanize_error

import homeassistant.helpers.config_validation as cv
from homeassistant.util import slugify
from script.translations import upload

from .model import Config, Integration

Expand Down
12 changes: 1 addition & 11 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,9 @@ ignore =
[isort]
# https://github.com/timothycrosley/isort
# https://github.com/timothycrosley/isort/wiki/isort-Settings
# splits long import on multiple lines indented by 4 spaces
multi_line_output = 3
include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True
line_length=88
indent = " "
# by default isort don't check module indexes
not_skip = __init__.py
profile = black
# will group `import x` and `from x import` of the same module.
force_sort_within_sections = true
sections = FUTURE,STDLIB,INBETWEENS,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
default_section = THIRDPARTY
known_first_party = homeassistant,tests
forced_separate = tests
combine_as_imports = true
Expand Down
3 changes: 2 additions & 1 deletion tests/async_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

if sys.version_info[:2] < (3, 8):
from asynctest.mock import * # noqa
from asynctest.mock import CoroutineMock as AsyncMock # noqa

AsyncMock = CoroutineMock # noqa: F405
else:
from unittest.mock import * # noqa
4 changes: 2 additions & 2 deletions tests/components/dsmr/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ async def test_v4_meter(hass, mock_connection_factory):
(connection_factory, transport, protocol) = mock_connection_factory

from dsmr_parser.obis_references import (
HOURLY_GAS_METER_READING,
ELECTRICITY_ACTIVE_TARIFF,
HOURLY_GAS_METER_READING,
)
from dsmr_parser.objects import CosemObject, MBusObject

Expand Down Expand Up @@ -198,8 +198,8 @@ async def test_v5_meter(hass, mock_connection_factory):
(connection_factory, transport, protocol) = mock_connection_factory

from dsmr_parser.obis_references import (
HOURLY_GAS_METER_READING,
ELECTRICITY_ACTIVE_TARIFF,
HOURLY_GAS_METER_READING,
)
from dsmr_parser.objects import CosemObject, MBusObject

Expand Down
2 changes: 1 addition & 1 deletion tests/components/mobile_app/test_http_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ async def test_registration(hass, hass_client, hass_admin_user):
async def test_registration_encryption(hass, hass_client):
"""Test that registrations happen."""
try:
from nacl.secret import SecretBox
from nacl.encoding import Base64Encoder
from nacl.secret import SecretBox
except (ImportError, OSError):
pytest.skip("libnacl/libsodium is not installed")
return
Expand Down
4 changes: 2 additions & 2 deletions tests/components/mobile_app/test_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
def encrypt_payload(secret_key, payload):
"""Return a encrypted payload given a key and dictionary of data."""
try:
from nacl.secret import SecretBox
from nacl.encoding import Base64Encoder
from nacl.secret import SecretBox
except (ImportError, OSError):
pytest.skip("libnacl/libsodium is not installed")
return
Expand All @@ -45,8 +45,8 @@ def encrypt_payload(secret_key, payload):
def decrypt_payload(secret_key, encrypted_data):
"""Return a decrypted payload given a key and a string of encrypted data."""
try:
from nacl.secret import SecretBox
from nacl.encoding import Base64Encoder
from nacl.secret import SecretBox
except (ImportError, OSError):
pytest.skip("libnacl/libsodium is not installed")
return
Expand Down
6 changes: 3 additions & 3 deletions tests/components/owntracks/test_device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1318,12 +1318,12 @@ def generate_ciphers(secret):
# PyNaCl ciphertext generation will fail if the module
# cannot be imported. However, the test for decryption
# also relies on this library and won't be run without it.
import pickle
import base64
import pickle

try:
from nacl.secret import SecretBox
from nacl.encoding import Base64Encoder
from nacl.secret import SecretBox

keylen = SecretBox.KEY_SIZE
key = secret.encode("utf-8")
Expand Down Expand Up @@ -1369,8 +1369,8 @@ def mock_cipher():

def mock_decrypt(ciphertext, key):
"""Decrypt/unpickle."""
import pickle
import base64
import pickle

(mkey, plaintext) = pickle.loads(base64.b64decode(ciphertext))
if key != mkey:
Expand Down
1 change: 1 addition & 0 deletions tests/components/rflink/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ async def test_race_condition(hass, monkeypatch):
async def test_not_connected(hass, monkeypatch):
"""Test Error when sending commands to a disconnected device."""
import pytest

from homeassistant.core import HomeAssistantError

test_device = RflinkCommand("DUMMY_DEVICE")
Expand Down
3 changes: 2 additions & 1 deletion tests/components/switcher_kis/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@
from tests.common import async_fire_time_changed, async_mock_service

if TYPE_CHECKING:
from tests.common import MockUser
from aioswitcher.devices import SwitcherV2Device

from tests.common import MockUser


async def test_failed_config(
hass: HomeAssistantType, mock_failed_bridge: Generator[None, Any, None]
Expand Down
1 change: 1 addition & 0 deletions tests/hassfest/test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import ast

import pytest

from script.hassfest.dependencies import ImportCollector


Expand Down

0 comments on commit 6ae9399

Please sign in to comment.