Upgrade isort to 5.4.2 (#37939)
This commit is contained in:
parent
1bf2c4d976
commit
6ae9399237
23 changed files with 38 additions and 41 deletions
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -5,8 +5,10 @@ import attr
|
|||
|
||||
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)
|
||||
|
|
|
@ -606,6 +606,7 @@ class HomeKit:
|
|||
type_cameras,
|
||||
type_covers,
|
||||
type_fans,
|
||||
type_humidifiers,
|
||||
type_lights,
|
||||
type_locks,
|
||||
type_media_players,
|
||||
|
@ -613,7 +614,6 @@ class HomeKit:
|
|||
type_sensors,
|
||||
type_switches,
|
||||
type_thermostats,
|
||||
type_humidifiers,
|
||||
)
|
||||
|
||||
for state in bridged_states:
|
||||
|
|
|
@ -30,8 +30,9 @@ from homeassistant.const import (
|
|||
)
|
||||
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__)
|
||||
|
|
|
@ -27,8 +27,8 @@ from . import (
|
|||
|
||||
# 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__)
|
||||
|
|
|
@ -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 "
|
||||
|
|
|
@ -26,13 +26,13 @@ ZigpyGroupType = zigpy.group.Group
|
|||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -43,8 +43,8 @@ class ZwaveFlowHandler(config_entries.ConfigFlow):
|
|||
|
||||
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
|
||||
|
|
|
@ -80,8 +80,8 @@ import homeassistant.util.uuid as uuid_util
|
|||
# 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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -8,9 +8,8 @@ import pkgutil
|
|||
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",
|
||||
|
|
|
@ -6,12 +6,12 @@ import logging
|
|||
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
|
||||
|
||||
|
|
12
setup.cfg
12
setup.cfg
|
@ -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
|
||||
|
|
|
@ -3,6 +3,7 @@ import sys
|
|||
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -22,8 +22,8 @@ _LOGGER = logging.getLogger(__name__)
|
|||
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
|
||||
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
@ -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:
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -39,9 +39,10 @@ from .consts import (
|
|||
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]
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import ast
|
||||
|
||||
import pytest
|
||||
|
||||
from script.hassfest.dependencies import ImportCollector
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue