Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imports optimized #290

Merged
merged 1 commit into from
Apr 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions miio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# flake8: noqa
from miio.protocol import Message, Utils
from miio.vacuumcontainers import (VacuumStatus, ConsumableStatus, DNDStatus,
CleaningDetails, CleaningSummary, Timer)
from miio.vacuum import Vacuum, VacuumException
from miio.chuangmi_plug import (Plug, PlugV1, PlugV3, ChuangmiPlug)
from miio.airpurifier import AirPurifier
from miio.airconditioningcompanion import AirConditioningCompanion
from miio.airhumidifier import AirHumidifier
from miio.waterpurifier import WaterPurifier
from miio.powerstrip import PowerStrip
from miio.airpurifier import AirPurifier
from miio.airqualitymonitor import AirQualityMonitor
from miio.ceil import Ceil
from miio.philips_bulb import PhilipsBulb
from miio.philips_eyecare import PhilipsEyecare
from miio.chuangmi_ir import ChuangmiIr
from miio.chuangmi_plug import (Plug, PlugV1, PlugV3, ChuangmiPlug)
from miio.device import Device, DeviceException
from miio.fan import Fan
from miio.wifispeaker import WifiSpeaker
from miio.philips_bulb import PhilipsBulb
from miio.philips_eyecare import PhilipsEyecare
from miio.powerstrip import PowerStrip
from miio.protocol import Message, Utils
from miio.vacuum import Vacuum, VacuumException
from miio.vacuumcontainers import (VacuumStatus, ConsumableStatus, DNDStatus,
CleaningDetails, CleaningSummary, Timer, )
from miio.waterpurifier import WaterPurifier
from miio.wifirepeater import WifiRepeater
from miio.airqualitymonitor import AirQualityMonitor
from miio.airconditioningcompanion import AirConditioningCompanion
from miio.wifispeaker import WifiSpeaker
from miio.yeelight import Yeelight
from miio.device import Device, DeviceException
from miio.discovery import Discovery
3 changes: 2 additions & 1 deletion miio/airconditioningcompanion.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from .device import Device
import enum
from typing import Optional

from .device import Device


class OperationMode(enum.Enum):
Heat = 0
Expand Down
5 changes: 3 additions & 2 deletions miio/airhumidifier.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import logging
import enum
from typing import Any, Dict, Optional
import logging
from collections import defaultdict
from typing import Any, Dict, Optional

from .device import Device, DeviceException

_LOGGER = logging.getLogger(__name__)
Expand Down
8 changes: 5 additions & 3 deletions miio/airpurifier.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import logging
import enum
import logging
import re
from typing import Any, Dict, Optional
from collections import defaultdict
from typing import Any, Dict, Optional

import click
from .device import Device, DeviceException

from .click_common import command, format_output, EnumType
from .device import Device, DeviceException

_LOGGER = logging.getLogger(__name__)

Expand Down
1 change: 1 addition & 0 deletions miio/airqualitymonitor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
from collections import defaultdict

from .device import Device

_LOGGER = logging.getLogger(__name__)
Expand Down
3 changes: 2 additions & 1 deletion miio/ceil.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
from typing import Any, Dict
from collections import defaultdict
from typing import Any, Dict

from .device import Device, DeviceException

_LOGGER = logging.getLogger(__name__)
Expand Down
9 changes: 5 additions & 4 deletions miio/ceil_cli.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# -*- coding: UTF-8 -*-
import logging
import click
import sys
from miio.click_common import (ExceptionHandlerGroup, validate_ip,
validate_token)
import miio # noqa: E402

import click

import miio # noqa: E402
from miio.click_common import (ExceptionHandlerGroup, validate_ip,
validate_token, )

_LOGGER = logging.getLogger(__name__)
pass_dev = click.make_pass_decorator(miio.Ceil)
Expand Down
2 changes: 2 additions & 0 deletions miio/chuangmi_ir.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import base64
import re

from construct import (
Struct, Const, Rebuild, this, len_, Adapter, Computed,
Int16ul, Int32ul, Int16ub, Array, BitStruct, BitsInteger,
)

from .device import Device, DeviceException


Expand Down
8 changes: 5 additions & 3 deletions miio/chuangmi_plug.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import logging
import click
from typing import Dict, Any, Optional
from collections import defaultdict
from typing import Dict, Any, Optional

import click

from .click_common import command, format_output
from .device import Device
from .utils import deprecated
from .click_common import command, format_output

_LOGGER = logging.getLogger(__name__)

Expand Down
2 changes: 2 additions & 0 deletions miio/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: UTF-8 -*-
import logging

import click

from miio.click_common import (
ExceptionHandlerGroup, DeviceGroupMeta, GlobalContextObject,
json_output,
Expand Down
15 changes: 8 additions & 7 deletions miio/device.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import binascii
import codecs
import datetime
import socket
import logging
import construct
import binascii
import click
from typing import Any, List, Optional # noqa: F401
import socket
from enum import Enum
from typing import Any, List, Optional # noqa: F401

import click
import construct

from .click_common import (
DeviceGroupMeta, command, format_output
DeviceGroupMeta, command, format_output,
)
from .protocol import Message
from .exceptions import DeviceException, DeviceError
from .protocol import Message

_LOGGER = logging.getLogger(__name__)

Expand Down
18 changes: 9 additions & 9 deletions miio/discovery.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import codecs
import inspect
import ipaddress
import logging
from functools import partial
from typing import Union, Callable, Dict, Optional # noqa: F401

import zeroconf
import ipaddress
import inspect
import codecs

from . import (Device, Vacuum, ChuangmiPlug, PowerStrip, AirPurifier, Ceil,
PhilipsBulb, PhilipsEyecare, ChuangmiIr, AirHumidifier,
WaterPurifier, WifiSpeaker, WifiRepeater, Yeelight)
WaterPurifier, WifiSpeaker, WifiRepeater, Yeelight, )
from .chuangmi_plug import (MODEL_CHUANGMI_PLUG_V1, MODEL_CHUANGMI_PLUG_V3,
MODEL_CHUANGMI_PLUG_M1)

from functools import partial
from typing import Union, Callable, Dict, Optional # noqa: F401

MODEL_CHUANGMI_PLUG_M1, )

_LOGGER = logging.getLogger(__name__)

Expand Down
11 changes: 6 additions & 5 deletions miio/extract_tokens.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import logging
import click
import tempfile
import sqlite3
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.backends import default_backend
import tempfile
from pprint import pformat as pf
from typing import Iterator

import attr
import click
from android_backup import AndroidBackup
from typing import Iterator
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes

logging.basicConfig(level=logging.INFO)
_LOGGER = logging.getLogger(__name__)
Expand Down
5 changes: 3 additions & 2 deletions miio/fan.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import enum
import logging
from .device import Device
from typing import Any, Dict, Optional
import enum

from .device import Device

_LOGGER = logging.getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion miio/philips_bulb.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
from typing import Any, Dict
from collections import defaultdict
from typing import Any, Dict

from .device import Device, DeviceException

_LOGGER = logging.getLogger(__name__)
Expand Down
3 changes: 2 additions & 1 deletion miio/philips_eyecare.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
from typing import Any, Dict
from collections import defaultdict
from typing import Any, Dict

from .device import Device, DeviceException

_LOGGER = logging.getLogger(__name__)
Expand Down
9 changes: 5 additions & 4 deletions miio/philips_eyecare_cli.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# -*- coding: UTF-8 -*-
import logging
import click
import sys
from miio.click_common import (ExceptionHandlerGroup, validate_ip,
validate_token)
import miio # noqa: E402

import click

import miio # noqa: E402
from miio.click_common import (ExceptionHandlerGroup, validate_ip,
validate_token, )

_LOGGER = logging.getLogger(__name__)
pass_dev = click.make_pass_decorator(miio.PhilipsEyecare)
Expand Down
11 changes: 6 additions & 5 deletions miio/plug_cli.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# -*- coding: UTF-8 -*-
import logging
import click
import ast
import logging
import sys
from typing import Any # noqa: F401
from miio.click_common import (ExceptionHandlerGroup, validate_ip,
validate_token)
import miio # noqa: E402

import click

import miio # noqa: E402
from miio.click_common import (ExceptionHandlerGroup, validate_ip,
validate_token, )

_LOGGER = logging.getLogger(__name__)
pass_dev = click.make_pass_decorator(miio.Plug)
Expand Down
5 changes: 3 additions & 2 deletions miio/powerstrip.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import logging
import enum
from typing import Dict, Any, Optional
import logging
from collections import defaultdict
from typing import Dict, Any, Optional

from .device import Device, DeviceException

_LOGGER = logging.getLogger(__name__)
Expand Down
10 changes: 4 additions & 6 deletions miio/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,20 @@

An usage example can be seen in the source of :func:`miio.Device.send`.
"""
import calendar
import datetime
import hashlib
import json
import logging
import calendar
from typing import Any, Dict, Tuple
from pprint import pprint as pp # noqa: F401

import construct
from construct import (Struct, Bytes, Const, Int16ub, Int32ub, GreedyBytes,
Adapter, Checksum, RawCopy, Rebuild, IfThenElse,
Default, Pointer, Hex, Probe)
import construct

from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
Default, Pointer, Hex, )
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import padding
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes

_LOGGER = logging.getLogger(__name__)

Expand Down
10 changes: 7 additions & 3 deletions miio/tests/test_airconditioningcompanion.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import string
from unittest import TestCase
from miio import AirConditioningCompanion
from miio.airconditioningcompanion import (OperationMode, FanSpeed, Power, SwingMode, Led,
AirConditioningCompanionStatus, STORAGE_SLOT_ID, )

import pytest

from miio import AirConditioningCompanion
from miio.airconditioningcompanion import (OperationMode, FanSpeed, Power,
SwingMode, Led,
AirConditioningCompanionStatus,
STORAGE_SLOT_ID, )

STATE_ON = ['on']
STATE_OFF = ['off']

Expand Down
6 changes: 4 additions & 2 deletions miio/tests/test_airhumidifier.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from unittest import TestCase

import pytest

from miio import AirHumidifier
from miio.airhumidifier import (OperationMode, LedBrightness,
AirHumidifierStatus, AirHumidifierException)
AirHumidifierStatus, AirHumidifierException, )
from .dummies import DummyDevice
import pytest


class DummyAirHumidifier(DummyDevice, AirHumidifier):
Expand Down
7 changes: 5 additions & 2 deletions miio/tests/test_airpurifier.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from unittest import TestCase

import pytest

from miio import AirPurifier
from miio.airpurifier import (OperationMode, LedBrightness, FilterType,
SleepMode, AirPurifierStatus, AirPurifierException)
SleepMode, AirPurifierStatus,
AirPurifierException, )
from .dummies import DummyDevice
import pytest


class DummyAirPurifier(DummyDevice, AirPurifier):
Expand Down
4 changes: 3 additions & 1 deletion miio/tests/test_airqualitymonitor.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from unittest import TestCase

import pytest

from miio import AirQualityMonitor
from miio.airqualitymonitor import AirQualityMonitorStatus
from .dummies import DummyDevice
import pytest


class DummyAirQualityMonitor(DummyDevice, AirQualityMonitor):
Expand Down
4 changes: 3 additions & 1 deletion miio/tests/test_ceil.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from unittest import TestCase

import pytest

from miio import Ceil
from miio.ceil import CeilStatus, CeilException
from .dummies import DummyDevice
import pytest


class DummyCeil(DummyDevice, Ceil):
Expand Down
Loading