Upgrade isort to 5.4.2 (#37939)

This commit is contained in:
Ville Skyttä 2020-08-29 09:23:55 +03:00 committed by GitHub
parent 1bf2c4d976
commit 6ae9399237
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 38 additions and 41 deletions

View File

@ -38,8 +38,8 @@ repos:
- --format=custom - --format=custom
- --configfile=tests/bandit.yaml - --configfile=tests/bandit.yaml
files: ^(homeassistant|script|tests)/.+\.py$ files: ^(homeassistant|script|tests)/.+\.py$
- repo: https://github.com/pre-commit/mirrors-isort - repo: https://github.com/timothycrosley/isort
rev: v4.3.21 rev: 5.4.2
hooks: hooks:
- id: isort - id: isort
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks

View File

@ -195,7 +195,7 @@ def closefds_osx(min_fd: int, max_fd: int) -> None:
get rid of. get rid of.
""" """
# pylint: disable=import-outside-toplevel # 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): for _fd in range(min_fd, max_fd):
try: try:

View File

@ -5,8 +5,10 @@ import attr
if TYPE_CHECKING: if TYPE_CHECKING:
# pylint: disable=unused-import # pylint: disable=unused-import
from homeassistant.helpers import entity_registry as ent_reg # noqa: F401 from homeassistant.helpers import ( # noqa: F401
from homeassistant.helpers import device_registry as dev_reg # noqa: F401 device_registry as dev_reg,
entity_registry as ent_reg,
)
@attr.s(slots=True) @attr.s(slots=True)

View File

@ -606,6 +606,7 @@ class HomeKit:
type_cameras, type_cameras,
type_covers, type_covers,
type_fans, type_fans,
type_humidifiers,
type_lights, type_lights,
type_locks, type_locks,
type_media_players, type_media_players,
@ -613,7 +614,6 @@ class HomeKit:
type_sensors, type_sensors,
type_switches, type_switches,
type_thermostats, type_thermostats,
type_humidifiers,
) )
for state in bridged_states: for state in bridged_states:

View File

@ -30,8 +30,9 @@ from homeassistant.const import (
) )
from homeassistant.core import callback 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 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 from .const import DOMAIN # pylint: disable=unused-import
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)

View File

@ -27,8 +27,8 @@ from . import (
# pylint: disable=ungrouped-imports # pylint: disable=ungrouped-imports
if TYPE_CHECKING: if TYPE_CHECKING:
from aioswitcher.devices import SwitcherV2Device
from aioswitcher.api.messages import SwitcherV2ControlResponseMSG from aioswitcher.api.messages import SwitcherV2ControlResponseMSG
from aioswitcher.devices import SwitcherV2Device
_LOGGER = getLogger(__name__) _LOGGER = getLogger(__name__)

View File

@ -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.) # (The model_dir is created during the manual setup process. See integration docs.)
# pylint: disable=import-outside-toplevel # 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.builders import model_builder
from object_detection.utils import config_util, label_map_util
except ImportError: except ImportError:
_LOGGER.error( _LOGGER.error(
"No TensorFlow Object Detection library found! Install or compile " "No TensorFlow Object Detection library found! Install or compile "

View File

@ -26,13 +26,13 @@ ZigpyGroupType = zigpy.group.Group
ZigpyZdoType = zigpy.zdo.ZDO ZigpyZdoType = zigpy.zdo.ZDO
if TYPE_CHECKING: if TYPE_CHECKING:
import homeassistant.components.zha.core.channels
import homeassistant.components.zha.core.channels as channels import homeassistant.components.zha.core.channels as channels
import homeassistant.components.zha.core.channels.base as base_channels import homeassistant.components.zha.core.channels.base as base_channels
import homeassistant.components.zha.core.device import homeassistant.components.zha.core.device
import homeassistant.components.zha.core.gateway import homeassistant.components.zha.core.gateway
import homeassistant.components.zha.core.group import homeassistant.components.zha.core.group
import homeassistant.components.zha.entity import homeassistant.components.zha.entity
import homeassistant.components.zha.core.channels
ChannelType = base_channels.ZigbeeChannel ChannelType = base_channels.ZigbeeChannel
ChannelsType = channels.Channels ChannelsType = channels.Channels

View File

@ -335,12 +335,13 @@ async def async_setup_entry(hass, config_entry):
Will automatically load components to support devices found on the network. Will automatically load components to support devices found on the network.
""" """
from pydispatch import dispatcher
# pylint: disable=import-error # pylint: disable=import-error
from openzwave.option import ZWaveOption
from openzwave.network import ZWaveNetwork
from openzwave.group import ZWaveGroup 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 # Merge config entry and yaml config
config = config_entry.data config = config_entry.data

View File

@ -43,8 +43,8 @@ class ZwaveFlowHandler(config_entries.ConfigFlow):
if user_input is not None: if user_input is not None:
# Check if USB path is valid # Check if USB path is valid
from openzwave.option import ZWaveOption
from openzwave.object import ZWaveException from openzwave.object import ZWaveException
from openzwave.option import ZWaveOption
try: try:
from functools import partial from functools import partial

View File

@ -80,8 +80,8 @@ import homeassistant.util.uuid as uuid_util
# Typing imports that create a circular dependency # Typing imports that create a circular dependency
if TYPE_CHECKING: if TYPE_CHECKING:
from homeassistant.auth import AuthManager from homeassistant.auth import AuthManager
from homeassistant.config_entries import ConfigEntries
from homeassistant.components.http import HomeAssistantHTTP from homeassistant.components.http import HomeAssistantHTTP
from homeassistant.config_entries import ConfigEntries
block_async_io.enable() block_async_io.enable()

View File

@ -5,7 +5,7 @@ black==20.8b1
codespell==1.17.1 codespell==1.17.1
flake8-docstrings==1.5.0 flake8-docstrings==1.5.0
flake8==3.8.3 flake8==3.8.3
isort==4.3.21 isort==5.4.2
pydocstyle==5.0.2 pydocstyle==5.0.2
pyupgrade==2.7.2 pyupgrade==2.7.2
yamllint==1.24.2 yamllint==1.24.2

View File

@ -8,9 +8,8 @@ import pkgutil
import re import re
import sys import sys
from script.hassfest.model import Integration
from homeassistant.util.yaml.loader import load_yaml from homeassistant.util.yaml.loader import load_yaml
from script.hassfest.model import Integration
COMMENT_REQUIREMENTS = ( COMMENT_REQUIREMENTS = (
"Adafruit_BBIO", "Adafruit_BBIO",

View File

@ -6,12 +6,12 @@ import logging
import re import re
from typing import Dict from typing import Dict
from script.translations import upload
import voluptuous as vol import voluptuous as vol
from voluptuous.humanize import humanize_error from voluptuous.humanize import humanize_error
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.util import slugify from homeassistant.util import slugify
from script.translations import upload
from .model import Config, Integration from .model import Config, Integration

View File

@ -38,19 +38,9 @@ ignore =
[isort] [isort]
# https://github.com/timothycrosley/isort # https://github.com/timothycrosley/isort
# https://github.com/timothycrosley/isort/wiki/isort-Settings # https://github.com/timothycrosley/isort/wiki/isort-Settings
# splits long import on multiple lines indented by 4 spaces profile = black
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
# will group `import x` and `from x import` of the same module. # will group `import x` and `from x import` of the same module.
force_sort_within_sections = true force_sort_within_sections = true
sections = FUTURE,STDLIB,INBETWEENS,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
default_section = THIRDPARTY
known_first_party = homeassistant,tests known_first_party = homeassistant,tests
forced_separate = tests forced_separate = tests
combine_as_imports = true combine_as_imports = true

View File

@ -3,6 +3,7 @@ import sys
if sys.version_info[:2] < (3, 8): if sys.version_info[:2] < (3, 8):
from asynctest.mock import * # noqa from asynctest.mock import * # noqa
from asynctest.mock import CoroutineMock as AsyncMock # noqa
AsyncMock = CoroutineMock # noqa: F405
else: else:
from unittest.mock import * # noqa from unittest.mock import * # noqa

View File

@ -153,8 +153,8 @@ async def test_v4_meter(hass, mock_connection_factory):
(connection_factory, transport, protocol) = mock_connection_factory (connection_factory, transport, protocol) = mock_connection_factory
from dsmr_parser.obis_references import ( from dsmr_parser.obis_references import (
HOURLY_GAS_METER_READING,
ELECTRICITY_ACTIVE_TARIFF, ELECTRICITY_ACTIVE_TARIFF,
HOURLY_GAS_METER_READING,
) )
from dsmr_parser.objects import CosemObject, MBusObject 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 (connection_factory, transport, protocol) = mock_connection_factory
from dsmr_parser.obis_references import ( from dsmr_parser.obis_references import (
HOURLY_GAS_METER_READING,
ELECTRICITY_ACTIVE_TARIFF, ELECTRICITY_ACTIVE_TARIFF,
HOURLY_GAS_METER_READING,
) )
from dsmr_parser.objects import CosemObject, MBusObject from dsmr_parser.objects import CosemObject, MBusObject

View File

@ -59,8 +59,8 @@ async def test_registration(hass, hass_client, hass_admin_user):
async def test_registration_encryption(hass, hass_client): async def test_registration_encryption(hass, hass_client):
"""Test that registrations happen.""" """Test that registrations happen."""
try: try:
from nacl.secret import SecretBox
from nacl.encoding import Base64Encoder from nacl.encoding import Base64Encoder
from nacl.secret import SecretBox
except (ImportError, OSError): except (ImportError, OSError):
pytest.skip("libnacl/libsodium is not installed") pytest.skip("libnacl/libsodium is not installed")
return return

View File

@ -22,8 +22,8 @@ _LOGGER = logging.getLogger(__name__)
def encrypt_payload(secret_key, payload): def encrypt_payload(secret_key, payload):
"""Return a encrypted payload given a key and dictionary of data.""" """Return a encrypted payload given a key and dictionary of data."""
try: try:
from nacl.secret import SecretBox
from nacl.encoding import Base64Encoder from nacl.encoding import Base64Encoder
from nacl.secret import SecretBox
except (ImportError, OSError): except (ImportError, OSError):
pytest.skip("libnacl/libsodium is not installed") pytest.skip("libnacl/libsodium is not installed")
return return
@ -45,8 +45,8 @@ def encrypt_payload(secret_key, payload):
def decrypt_payload(secret_key, encrypted_data): def decrypt_payload(secret_key, encrypted_data):
"""Return a decrypted payload given a key and a string of encrypted data.""" """Return a decrypted payload given a key and a string of encrypted data."""
try: try:
from nacl.secret import SecretBox
from nacl.encoding import Base64Encoder from nacl.encoding import Base64Encoder
from nacl.secret import SecretBox
except (ImportError, OSError): except (ImportError, OSError):
pytest.skip("libnacl/libsodium is not installed") pytest.skip("libnacl/libsodium is not installed")
return return

View File

@ -1318,12 +1318,12 @@ def generate_ciphers(secret):
# PyNaCl ciphertext generation will fail if the module # PyNaCl ciphertext generation will fail if the module
# cannot be imported. However, the test for decryption # cannot be imported. However, the test for decryption
# also relies on this library and won't be run without it. # also relies on this library and won't be run without it.
import pickle
import base64 import base64
import pickle
try: try:
from nacl.secret import SecretBox
from nacl.encoding import Base64Encoder from nacl.encoding import Base64Encoder
from nacl.secret import SecretBox
keylen = SecretBox.KEY_SIZE keylen = SecretBox.KEY_SIZE
key = secret.encode("utf-8") key = secret.encode("utf-8")
@ -1369,8 +1369,8 @@ def mock_cipher():
def mock_decrypt(ciphertext, key): def mock_decrypt(ciphertext, key):
"""Decrypt/unpickle.""" """Decrypt/unpickle."""
import pickle
import base64 import base64
import pickle
(mkey, plaintext) = pickle.loads(base64.b64decode(ciphertext)) (mkey, plaintext) = pickle.loads(base64.b64decode(ciphertext))
if key != mkey: if key != mkey:

View File

@ -337,6 +337,7 @@ async def test_race_condition(hass, monkeypatch):
async def test_not_connected(hass, monkeypatch): async def test_not_connected(hass, monkeypatch):
"""Test Error when sending commands to a disconnected device.""" """Test Error when sending commands to a disconnected device."""
import pytest import pytest
from homeassistant.core import HomeAssistantError from homeassistant.core import HomeAssistantError
test_device = RflinkCommand("DUMMY_DEVICE") test_device = RflinkCommand("DUMMY_DEVICE")

View File

@ -39,9 +39,10 @@ from .consts import (
from tests.common import async_fire_time_changed, async_mock_service from tests.common import async_fire_time_changed, async_mock_service
if TYPE_CHECKING: if TYPE_CHECKING:
from tests.common import MockUser
from aioswitcher.devices import SwitcherV2Device from aioswitcher.devices import SwitcherV2Device
from tests.common import MockUser
async def test_failed_config( async def test_failed_config(
hass: HomeAssistantType, mock_failed_bridge: Generator[None, Any, None] hass: HomeAssistantType, mock_failed_bridge: Generator[None, Any, None]

View File

@ -2,6 +2,7 @@
import ast import ast
import pytest import pytest
from script.hassfest.dependencies import ImportCollector from script.hassfest.dependencies import ImportCollector