Skip to content

Commit

Permalink
Update pre-commit hooks (#1642)
Browse files Browse the repository at this point in the history
Update pre-commit hooks and fix issues found by newer versions of
enabled hooks.
  • Loading branch information
rytilahti committed Jan 1, 2023
1 parent aa2122b commit c3c845c
Show file tree
Hide file tree
Showing 24 changed files with 88 additions and 90 deletions.
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -12,7 +12,7 @@ repos:
- id: check-ast

- repo: https://github.com/psf/black
rev: 22.6.0
rev: 22.12.0
hooks:
- id: black
language_version: python3
Expand All @@ -24,18 +24,18 @@ repos:
additional_dependencies: [toml]

- repo: https://github.com/PyCQA/doc8
rev: 0.11.2
rev: v1.1.1
hooks:
- id: doc8

- repo: https://github.com/myint/docformatter
rev: v1.4
rev: v1.5.1
hooks:
- id: docformatter
args: [--in-place, --wrap-summaries, '88', --wrap-descriptions, '88']

- repo: https://github.com/pycqa/flake8
rev: 3.9.2
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies: [flake8-docstrings, flake8-bugbear, flake8-builtins, flake8-print, flake8-pytest-style, flake8-return, flake8-simplify, flake8-annotations]
Expand All @@ -48,13 +48,13 @@ repos:


- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.961
rev: v0.991
hooks:
- id: mypy
additional_dependencies: [types-attrs, types-PyYAML, types-requests, types-pytz, types-croniter, types-freezegun]

- repo: https://github.com/asottile/pyupgrade
rev: v2.37.1
rev: v3.3.1
hooks:
- id: pyupgrade
args: ['--py38-plus']
10 changes: 5 additions & 5 deletions miio/airconditioningcompanion.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,12 @@ class AirConditioningCompanion(Device):

def __init__(
self,
ip: str = None,
token: str = None,
ip: Optional[str] = None,
token: Optional[str] = None,
start_id: int = 0,
debug: int = 0,
lazy_discover: bool = True,
timeout: int = None,
timeout: Optional[int] = None,
model: str = MODEL_ACPARTNER_V2,
) -> None:
super().__init__(
Expand Down Expand Up @@ -413,8 +413,8 @@ def send_configuration(
class AirConditioningCompanionV3(AirConditioningCompanion):
def __init__(
self,
ip: str = None,
token: str = None,
ip: Optional[str] = None,
token: Optional[str] = None,
start_id: int = 0,
debug: int = 0,
lazy_discover: bool = True,
Expand Down
10 changes: 5 additions & 5 deletions miio/airconditioningcompanionMCN.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ class AirConditioningCompanionMcn02(Device):

def __init__(
self,
ip: str = None,
token: str = None,
start_id: int = None,
ip: Optional[str] = None,
token: Optional[str] = None,
start_id: Optional[int] = None,
debug: int = 0,
lazy_discover: bool = True,
timeout: int = None,
timeout: Optional[int] = None,
model: str = MODEL_ACPARTNER_MCN02,
) -> None:
if start_id is None:
Expand Down Expand Up @@ -153,7 +153,7 @@ def off(self):
@command(
default_output=format_output("Sending a command to the air conditioner"),
)
def send_command(self, command: str, parameters: Any = None) -> Any:
def send_command(self, command: str, parameters: Optional[Any] = None) -> Any:
"""Send a command to the air conditioner.
:param str command: Command to execute
Expand Down
5 changes: 2 additions & 3 deletions miio/click_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import logging
import re
from functools import partial, wraps
from typing import Any, Callable, ClassVar, Dict, List, Set, Type, Union
from typing import Any, Callable, ClassVar, Dict, List, Optional, Set, Type, Union

import click

Expand Down Expand Up @@ -104,13 +104,12 @@ def convert(self, value, param, ctx):


class GlobalContextObject:
def __init__(self, debug: int = 0, output: Callable = None):
def __init__(self, debug: int = 0, output: Optional[Callable] = None):
self.debug = debug
self.output = output


class DeviceGroupMeta(type):

_device_classes: Set[Type] = set()
_supported_models: ClassVar[List[str]]
_mappings: ClassVar[Dict[str, Any]]
Expand Down
4 changes: 2 additions & 2 deletions miio/cooker.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def raw(self) -> str:


class InteractionTimeouts(DeviceStatus):
def __init__(self, timeouts: str = None):
def __init__(self, timeouts: Optional[str] = None):
"""Example timeouts: 05040f, 05060f.
Data structure:
Expand Down Expand Up @@ -298,7 +298,7 @@ def __str__(self) -> str:


class CookerSettings(DeviceStatus):
def __init__(self, settings: str = None):
def __init__(self, settings: Optional[str] = None):
"""Example settings: 1407, 0607, 0207.
Data structure:
Expand Down
12 changes: 6 additions & 6 deletions miio/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ def __init_subclass__(cls, **kwargs):

def __init__(
self,
ip: str = None,
token: str = None,
ip: Optional[str] = None,
token: Optional[str] = None,
start_id: int = 0,
debug: int = 0,
lazy_discover: bool = True,
timeout: int = None,
timeout: Optional[int] = None,
*,
model: str = None,
model: Optional[str] = None,
) -> None:
self.ip = ip
self.token: Optional[str] = token
Expand All @@ -74,8 +74,8 @@ def __init__(
def send(
self,
command: str,
parameters: Any = None,
retry_count: int = None,
parameters: Optional[Any] = None,
retry_count: Optional[int] = None,
*,
extra_parameters=None,
) -> Any:
Expand Down
6 changes: 3 additions & 3 deletions miio/extract_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class BackupDatabaseReader:
"""

def __init__(self, dump_raw=False):
self.dump_raw = dump_raw
self._dump_raw = dump_raw

@staticmethod
def dump_raw(dev):
Expand Down Expand Up @@ -93,7 +93,7 @@ def read_apple(self) -> Iterator[DeviceConfig]:
_LOGGER.info("Reading tokens from Apple DB")
c = self.conn.execute("SELECT * FROM ZDEVICE WHERE ZTOKEN IS NOT '';")
for dev in c.fetchall():
if self.dump_raw:
if self._dump_raw:
BackupDatabaseReader.dump_raw(dev)
ip = dev["ZLOCALIP"]
mac = dev["ZMAC"]
Expand All @@ -111,7 +111,7 @@ def read_android(self) -> Iterator[DeviceConfig]:
_LOGGER.info("Reading tokens from Android DB")
c = self.conn.execute("SELECT * FROM devicerecord WHERE token IS NOT '';")
for dev in c.fetchall():
if self.dump_raw:
if self._dump_raw:
BackupDatabaseReader.dump_raw(dev)
ip = dev["localIP"]
mac = dev["mac"]
Expand Down
10 changes: 5 additions & 5 deletions miio/gateway/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
import os
import sys
from typing import Callable, Dict, List
from typing import Callable, Dict, List, Optional

import click
import yaml
Expand Down Expand Up @@ -89,14 +89,14 @@ class Gateway(Device):

def __init__(
self,
ip: str = None,
token: str = None,
ip: Optional[str] = None,
token: Optional[str] = None,
start_id: int = 0,
debug: int = 0,
lazy_discover: bool = True,
timeout: int = None,
timeout: Optional[int] = None,
*,
model: str = None,
model: Optional[str] = None,
push_server=None,
) -> None:
super().__init__(
Expand Down
4 changes: 2 additions & 2 deletions miio/gateway/gatewaydevice.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Xiaomi Gateway device base class."""

import logging
from typing import TYPE_CHECKING, List
from typing import TYPE_CHECKING, List, Optional

from ..exceptions import DeviceException

Expand All @@ -20,7 +20,7 @@ class GatewayDevice:

def __init__(
self,
parent: "Gateway" = None,
parent: Optional["Gateway"] = None,
) -> None:
if parent is None:
raise DeviceException(
Expand Down
6 changes: 3 additions & 3 deletions miio/huizuo.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,12 @@ class Huizuo(MiotDevice):

def __init__(
self,
ip: str = None,
token: str = None,
ip: Optional[str] = None,
token: Optional[str] = None,
start_id: int = 0,
debug: int = 0,
lazy_discover: bool = True,
timeout: int = None,
timeout: Optional[int] = None,
model: str = MODEL_HUIZUO_PIS123,
) -> None:

Expand Down
8 changes: 4 additions & 4 deletions miio/integrations/fan/dmaker/fan.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict
from typing import Any, Dict, Optional

import click

Expand Down Expand Up @@ -95,12 +95,12 @@ class FanP5(Device):

def __init__(
self,
ip: str = None,
token: str = None,
ip: Optional[str] = None,
token: Optional[str] = None,
start_id: int = 0,
debug: int = 0,
lazy_discover: bool = True,
timeout: int = None,
timeout: Optional[int] = None,
model: str = MODEL_FAN_P5,
) -> None:
super().__init__(
Expand Down
8 changes: 4 additions & 4 deletions miio/integrations/fan/dmaker/fan_miot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import enum
from typing import Any, Dict
from typing import Any, Dict, Optional

import click

Expand Down Expand Up @@ -406,12 +406,12 @@ class Fan1C(MiotDevice):

def __init__(
self,
ip: str = None,
token: str = None,
ip: Optional[str] = None,
token: Optional[str] = None,
start_id: int = 0,
debug: int = 0,
lazy_discover: bool = True,
timeout: int = None,
timeout: Optional[int] = None,
model: str = MODEL_FAN_1C,
) -> None:
super().__init__(
Expand Down
11 changes: 5 additions & 6 deletions miio/integrations/genericmiot/genericmiot.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ class GenericMiot(MiotDevice):

def __init__(
self,
ip: str = None,
token: str = None,
ip: Optional[str] = None,
token: Optional[str] = None,
start_id: int = 0,
debug: int = 0,
lazy_discover: bool = True,
timeout: int = None,
timeout: Optional[int] = None,
*,
model: str = None,
mapping: MiotMapping = None,
model: Optional[str] = None,
mapping: Optional[MiotMapping] = None,
):
super().__init__(
ip,
Expand Down Expand Up @@ -269,7 +269,6 @@ def _create_sensors_and_settings(self, serv: MiotService):

def _descriptor_for_property(self, prop: MiotProperty):
"""Create a descriptor based on the property information."""
desc: SettingDescriptor
name = prop.description
property_name = prop.name

Expand Down
9 changes: 4 additions & 5 deletions miio/integrations/light/yeelight/yeelight.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class YeelightMode(IntEnum):

class YeelightSubLight(DeviceStatus):
def __init__(self, data, type):

self.data = data
self.type = type

Expand Down Expand Up @@ -293,13 +292,13 @@ class Yeelight(Device, LightInterface):

def __init__(
self,
ip: str = None,
token: str = None,
ip: Optional[str] = None,
token: Optional[str] = None,
start_id: int = 0,
debug: int = 0,
lazy_discover: bool = True,
timeout: int = None,
model: str = None,
timeout: Optional[int] = None,
model: Optional[str] = None,
) -> None:
super().__init__(
ip, token, start_id, debug, lazy_discover, timeout=timeout, model=model
Expand Down
4 changes: 2 additions & 2 deletions miio/integrations/vacuum/roborock/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ class RoborockVacuum(Device, VacuumInterface):
def __init__(
self,
ip: str,
token: str = None,
token: Optional[str] = None,
start_id: int = 0,
debug: int = 0,
lazy_discover: bool = True,
timeout: int = None,
timeout: Optional[int] = None,
*,
model=None,
):
Expand Down
1 change: 0 additions & 1 deletion miio/integrations/vacuum/roborock/vacuum_tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@


class Control(enum.Enum):

Quit = "q"
Forward = "w"
ForwardFast = "W"
Expand Down
Loading

0 comments on commit c3c845c

Please sign in to comment.