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

Update pre-commit hooks & dependencies #1899

Merged
merged 2 commits into from
Feb 15, 2024
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
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:
- id: check-ast

- repo: https://github.com/psf/black
rev: 23.10.0
rev: 24.2.0
hooks:
- id: black
language_version: python3
Expand All @@ -36,20 +36,20 @@ repos:
# args: [--in-place, --wrap-summaries, '88', --wrap-descriptions, '88', --black

- repo: https://github.com/pycqa/flake8
rev: 6.1.0
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies: [flake8-docstrings, flake8-bugbear, flake8-builtins, flake8-print, flake8-pytest-style, flake8-return, flake8-simplify, flake8-annotations]

- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
rev: 1.7.7
hooks:
- id: bandit
args: [-x, 'tests', -x, '**/test_*.py']


- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.6.1
rev: v1.8.0
hooks:
- id: mypy
additional_dependencies: [types-attrs, types-PyYAML, types-requests, types-pytz, types-croniter, types-freezegun]
Expand Down
1 change: 1 addition & 0 deletions miio/click_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

This file contains common functions for cli tools.
"""

import ast
import ipaddress
import json
Expand Down
1 change: 1 addition & 0 deletions miio/descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
If you are developing an integration, prefer :func:`~miio.devicestatus.sensor`, :func:`~miio.devicestatus.setting`, and
:func:`~miio.devicestatus.action` decorators over creating the descriptors manually.
"""

from enum import Enum, Flag, auto
from typing import Any, Callable, Dict, List, Optional, Type

Expand Down
1 change: 1 addition & 0 deletions miio/devtools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Command-line interface for devtools."""

import logging

import click
Expand Down
3 changes: 2 additions & 1 deletion miio/devtools/pcapparser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Parse PCAP files for miio traffic."""

from collections import Counter, defaultdict
from ipaddress import ip_address
from pprint import pformat as pf
Expand Down Expand Up @@ -51,7 +52,7 @@
try:
decrypted = Message.parse(data, token=bytes.fromhex(token))
break
except BaseException:
except BaseException: # noqa: B036

Check warning on line 55 in miio/devtools/pcapparser.py

View check run for this annotation

Codecov / codecov/patch

miio/devtools/pcapparser.py#L55

Added line #L55 was not covered by tests
continue

if decrypted is None:
Expand Down
1 change: 1 addition & 0 deletions miio/devtools/simulators/common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Common functionalities for miio and miot simulators."""

from hashlib import md5


Expand Down
1 change: 1 addition & 0 deletions miio/devtools/simulators/miiosimulator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of miio simulator."""

import asyncio
import json
import logging
Expand Down
1 change: 1 addition & 0 deletions miio/identifiers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Compat layer for homeassistant."""

from enum import Enum, auto


Expand Down
6 changes: 3 additions & 3 deletions miio/integrations/cgllc/airmonitor/airqualitymonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ def off(self):
@command(
click.argument("display_clock", type=bool),
default_output=format_output(
lambda led: "Turning on display clock"
if led
else "Turning off display clock"
lambda led: (
"Turning on display clock" if led else "Turning off display clock"
)
),
)
def set_display_clock(self, display_clock: bool):
Expand Down
8 changes: 5 additions & 3 deletions miio/integrations/chuangmi/camera/chuangmi_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,11 @@ def set_motion_sensitivity(self, sensitivity: MotionDetectionSensitivity):
"""Set motion sensitivity (high, low)."""
return self.send(
"set_motion_region",
CONST_HIGH_SENSITIVITY
if sensitivity == MotionDetectionSensitivity.High
else CONST_LOW_SENSITIVITY,
(
CONST_HIGH_SENSITIVITY
if sensitivity == MotionDetectionSensitivity.High
else CONST_LOW_SENSITIVITY
),
)

@command(
Expand Down
6 changes: 3 additions & 3 deletions miio/integrations/chuangmi/plug/chuangmi_plug.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ def usb_off(self):
@command(
click.argument("wifi_led", type=bool),
default_output=format_output(
lambda wifi_led: "Turning on WiFi LED"
if wifi_led
else "Turning off WiFi LED"
lambda wifi_led: (
"Turning on WiFi LED" if wifi_led else "Turning off WiFi LED"
)
),
)
def set_wifi_led(self, wifi_led: bool):
Expand Down
8 changes: 5 additions & 3 deletions miio/integrations/chuangmi/remote/chuangmi_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,11 @@ def play(self, command: str):
@command(
click.argument("indicator_led", type=bool),
default_output=format_output(
lambda indicator_led: "Turning on indicator LED"
if indicator_led
else "Turning off indicator LED"
lambda indicator_led: (
"Turning on indicator LED"
if indicator_led
else "Turning off indicator LED"
)
),
)
def set_indicator_led(self, indicator_led: bool):
Expand Down
8 changes: 5 additions & 3 deletions miio/integrations/deerma/humidifier/airhumidifier_mjjsq.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,11 @@ def set_target_humidity(self, humidity: int):
@command(
click.argument("protection", type=bool),
default_output=format_output(
lambda protection: "Turning on wet protection"
if protection
else "Turning off wet protection"
lambda protection: (
"Turning on wet protection"
if protection
else "Turning off wet protection"
)
),
)
def set_wet_protection(self, protection: bool):
Expand Down
6 changes: 3 additions & 3 deletions miio/integrations/dmaker/fan/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ def set_angle(self, angle: int):
@command(
click.argument("oscillate", type=bool),
default_output=format_output(
lambda oscillate: "Turning on oscillate"
if oscillate
else "Turning off oscillate"
lambda oscillate: (
"Turning on oscillate" if oscillate else "Turning off oscillate"
)
),
)
def set_oscillate(self, oscillate: bool):
Expand Down
12 changes: 6 additions & 6 deletions miio/integrations/dmaker/fan/fan_miot.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,9 @@ def set_angle(self, angle: int):
@command(
click.argument("oscillate", type=bool),
default_output=format_output(
lambda oscillate: "Turning on oscillate"
if oscillate
else "Turning off oscillate"
lambda oscillate: (
"Turning on oscillate" if oscillate else "Turning off oscillate"
)
),
)
def set_oscillate(self, oscillate: bool):
Expand Down Expand Up @@ -527,9 +527,9 @@ def set_speed(self, speed: int):
@command(
click.argument("oscillate", type=bool),
default_output=format_output(
lambda oscillate: "Turning on oscillate"
if oscillate
else "Turning off oscillate"
lambda oscillate: (
"Turning on oscillate" if oscillate else "Turning off oscillate"
)
),
)
def set_oscillate(self, oscillate: bool):
Expand Down
6 changes: 3 additions & 3 deletions miio/integrations/leshow/fan/fan_leshow.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ def set_speed(self, speed: int):
@command(
click.argument("oscillate", type=bool),
default_output=format_output(
lambda oscillate: "Turning on oscillate"
if oscillate
else "Turning off oscillate"
lambda oscillate: (
"Turning on oscillate" if oscillate else "Turning off oscillate"
)
),
)
def set_oscillate(self, oscillate: bool):
Expand Down
1 change: 1 addition & 0 deletions miio/integrations/lumi/camera/aqaracamera.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
.. todo:: add sdcard status & fix all TODOS
.. todo:: add tests
"""

import logging
from enum import IntEnum
from typing import Any, Dict
Expand Down
8 changes: 5 additions & 3 deletions miio/integrations/philips/light/philips_rwread.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,11 @@ def delay_off(self, seconds: int):
@command(
click.argument("motion_detection", type=bool),
default_output=format_output(
lambda motion_detection: "Turning on motion detection"
if motion_detection
else "Turning off motion detection"
lambda motion_detection: (
"Turning on motion detection"
if motion_detection
else "Turning off motion detection"
)
),
)
def set_motion_detection(self, motion_detection: bool):
Expand Down
1 change: 0 additions & 1 deletion miio/integrations/roidmi/vacuum/roidmivacuum_miot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Vacuum Eve Plus (roidmi.vacuum.v60)"""


import json
import logging
import math
Expand Down
1 change: 1 addition & 0 deletions miio/integrations/tinymu/toiletlid/test_toiletlid.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
Filter remaining: 100%
Filter remaining time: 180
"""

from unittest import TestCase

import pytest
Expand Down
1 change: 1 addition & 0 deletions miio/integrations/viomi/vacuum/viomivacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
- Clean History Path - MISSING (historyPath)
- Map plan - MISSING (map_plan)
"""

import itertools
import logging
import time
Expand Down
24 changes: 13 additions & 11 deletions miio/integrations/xiaomi/aircondition/airconditioner_miot.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,9 @@ def set_dryer(self, dryer: bool):
@command(
click.argument("sleep_mode", type=bool),
default_output=format_output(
lambda sleep_mode: "Turning on sleep mode"
if sleep_mode
else "Turning off sleep mode"
lambda sleep_mode: (
"Turning on sleep mode" if sleep_mode else "Turning off sleep mode"
)
),
)
def set_sleep_mode(self, sleep_mode: bool):
Expand All @@ -400,9 +400,11 @@ def set_fan_speed(self, fan_speed: FanSpeed):
@command(
click.argument("vertical_swing", type=bool),
default_output=format_output(
lambda vertical_swing: "Turning on vertical swing"
if vertical_swing
else "Turning off vertical swing"
lambda vertical_swing: (
"Turning on vertical swing"
if vertical_swing
else "Turning off vertical swing"
)
),
)
def set_vertical_swing(self, vertical_swing: bool):
Expand Down Expand Up @@ -443,11 +445,11 @@ def set_fan_speed_percent(self, fan_speed_percent):
click.argument("minutes", type=int),
click.argument("delay_on", type=bool),
default_output=format_output(
lambda minutes, delay_on: "Setting timer to delay on after "
+ str(minutes)
+ " minutes"
if delay_on
else "Setting timer to delay off after " + str(minutes) + " minutes"
lambda minutes, delay_on: (
"Setting timer to delay on after " + str(minutes) + " minutes"
if delay_on
else "Setting timer to delay off after " + str(minutes) + " minutes"
)
),
)
def set_timer(self, minutes, delay_on):
Expand Down
6 changes: 3 additions & 3 deletions miio/integrations/xiaomi/repeater/wifirepeater.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ def set_configuration(self, ssid: str, password: str, ssid_hidden: bool = False)

@command(
default_output=format_output(
lambda result: "WiFi roaming is enabled"
if result
else "WiFi roaming is disabled"
lambda result: (
"WiFi roaming is enabled" if result else "WiFi roaming is disabled"
)
)
)
def wifi_roaming(self) -> bool:
Expand Down
12 changes: 6 additions & 6 deletions miio/integrations/zhimi/airpurifier/airpurifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,9 @@ def set_volume(self, volume: int):
@command(
click.argument("learn_mode", type=bool),
default_output=format_output(
lambda learn_mode: "Turning on learn mode"
if learn_mode
else "Turning off learn mode"
lambda learn_mode: (
"Turning on learn mode" if learn_mode else "Turning off learn mode"
)
),
)
def set_learn_mode(self, learn_mode: bool):
Expand All @@ -497,9 +497,9 @@ def set_learn_mode(self, learn_mode: bool):
@command(
click.argument("auto_detect", type=bool),
default_output=format_output(
lambda auto_detect: "Turning on auto detect"
if auto_detect
else "Turning off auto detect"
lambda auto_detect: (
"Turning on auto detect" if auto_detect else "Turning off auto detect"
)
),
)
def set_auto_detect(self, auto_detect: bool):
Expand Down
6 changes: 3 additions & 3 deletions miio/integrations/zhimi/airpurifier/airpurifier_miot.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,9 +600,9 @@ def set_buzzer(self, buzzer: bool):
@command(
click.argument("gestures", type=bool),
default_output=format_output(
lambda gestures: "Turning on gestures"
if gestures
else "Turning off gestures"
lambda gestures: (
"Turning on gestures" if gestures else "Turning off gestures"
)
),
)
def set_gestures(self, gestures: bool):
Expand Down
6 changes: 3 additions & 3 deletions miio/integrations/zhimi/fan/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,9 @@ def set_angle(self, angle: int):
@command(
click.argument("oscillate", type=bool),
default_output=format_output(
lambda oscillate: "Turning on oscillate"
if oscillate
else "Turning off oscillate"
lambda oscillate: (
"Turning on oscillate" if oscillate else "Turning off oscillate"
)
),
)
def set_oscillate(self, oscillate: bool):
Expand Down
6 changes: 3 additions & 3 deletions miio/integrations/zhimi/fan/zhimi_miot.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,9 @@ def set_angle(self, angle: int):
@command(
click.argument("oscillate", type=bool),
default_output=format_output(
lambda oscillate: "Turning on oscillate"
if oscillate
else "Turning off oscillate"
lambda oscillate: (
"Turning on oscillate" if oscillate else "Turning off oscillate"
)
),
)
def set_oscillate(self, oscillate: bool):
Expand Down
6 changes: 3 additions & 3 deletions miio/integrations/zhimi/humidifier/airhumidifier_miot.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,9 @@ def set_dry(self, dry: bool):
@command(
click.argument("clean_mode", type=bool),
default_output=format_output(
lambda clean_mode: "Turning on clean mode"
if clean_mode
else "Turning off clean mode"
lambda clean_mode: (
"Turning on clean mode" if clean_mode else "Turning off clean mode"
)
),
)
def set_clean_mode(self, clean_mode: bool):
Expand Down
Loading
Loading