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

Add docformatter to pre-commit hooks #914

Merged
merged 4 commits into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ repos:
- id: black
language_version: python3

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


- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
Expand Down
13 changes: 6 additions & 7 deletions miio/airconditioner_miot.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ class AirConditionerMiotException(DeviceException):

class CleaningStatus:
def __init__(self, status: str):
"""
Auto clean mode indicator.
"""Auto clean mode indicator.

Value format: <int>,<int>,<int>,<int>
Integer 1: whether auto cleaning mode started.
Expand Down Expand Up @@ -124,8 +123,7 @@ class FanSpeed(enum.Enum):

class TimerStatus:
def __init__(self, status):
"""
Countdown timer indicator.
"""Countdown timer indicator.

Value format: <int>,<int>,<int>,<int>
Integer 1: whether the timer is enabled.
Expand Down Expand Up @@ -173,7 +171,8 @@ def __repr__(self) -> str:


class AirConditionerMiotStatus:
"""Container for status reports from the air conditioner which uses MIoT protocol."""
"""Container for status reports from the air conditioner which uses MIoT
protocol."""

def __init__(self, data: Dict[str, Any]) -> None:
"""
Expand Down Expand Up @@ -523,8 +522,8 @@ def set_fan_speed_percent(self, fan_speed_percent):
),
)
def set_timer(self, minutes, delay_on):
"""
Set countdown timer minutes and if it would be turned on after timeout.
"""Set countdown timer minutes and if it would be turned on after timeout.

Set minutes to 0 would disable the timer.
"""
return self.set_property(
Expand Down
26 changes: 9 additions & 17 deletions miio/airconditioningcompanion.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ class AirConditioningCompanionStatus:
"""Container for status reports of the Xiaomi AC Companion."""

def __init__(self, data):
"""
Device model: lumi.acpartner.v2
"""Device model: lumi.acpartner.v2.

Response of "get_model_and_state":
['010500978022222102', '010201190280222221', '2']
Expand Down Expand Up @@ -133,33 +132,25 @@ def device_type(self) -> int:

@property
def air_condition_brand(self) -> int:
"""
Brand of the air conditioner.
"""Brand of the air conditioner.

Known brand ids are 0x0182, 0x0097, 0x0037, 0x0202, 0x02782, 0x0197, 0x0192.
"""
return int(self.air_condition_model[2:4].hex(), 16)

@property
def air_condition_remote(self) -> int:
"""
Known remote ids:

0x80111111, 0x80111112 (brand: 0x0182)
0x80222221 (brand: 0x0097)
0x80333331 (brand: 0x0037)
0x80444441 (brand: 0x0202)
0x80555551 (brand: 0x2782)
0x80777771 (brand: 0x0197)
0x80666661 (brand: 0x0192)
"""Known remote ids:

0x80111111, 0x80111112 (brand: 0x0182) 0x80222221 (brand: 0x0097) 0x80333331
rytilahti marked this conversation as resolved.
Show resolved Hide resolved
(brand: 0x0037) 0x80444441 (brand: 0x0202) 0x80555551 (brand: 0x2782) 0x80777771
(brand: 0x0197) 0x80666661 (brand: 0x0192)
"""
return int(self.air_condition_model[4:8].hex(), 16)

@property
def state_format(self) -> int:
"""
Version number of the state format.
"""Version number of the state format.

Known values are: 1, 2, 3
"""
Expand Down Expand Up @@ -395,7 +386,8 @@ def send_ir_code(self, model: str, code: str, slot: int = 0):
def send_command(self, command: str):
"""Send a command to the air conditioner.

:param str command: Command to execute"""
:param str command: Command to execute
"""
return self.send("send_cmd", [str(command)])

@command(
Expand Down
10 changes: 5 additions & 5 deletions miio/airconditioningcompanionMCN.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ class AirConditioningCompanionStatus:
"""Container for status reports of the Xiaomi AC Companion."""

def __init__(self, data):
"""
Device model: lumi.acpartner.mcn02
"""Device model: lumi.acpartner.mcn02.

Response of "get_prop, params:['power', 'mode', 'tar_temp', 'fan_level', 'ver_swing', 'load_power']":
['on', 'dry', 16, 'small_fan', 'off', 84.0]
Response of "get_prop, params:['power', 'mode', 'tar_temp', 'fan_level',
'ver_swing', 'load_power']": ['on', 'dry', 16, 'small_fan', 'off', 84.0]
rytilahti marked this conversation as resolved.
Show resolved Hide resolved
"""
self.data = data

Expand Down Expand Up @@ -174,5 +173,6 @@ def off(self):
def send_command(self, command: str, parameters: Any = None) -> Any:
"""Send a command to the air conditioner.

:param str command: Command to execute"""
:param str command: Command to execute
"""
return self.send(command, parameters)
13 changes: 9 additions & 4 deletions miio/airdehumidifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ class AirDehumidifierStatus:
"""Container for status reports from the air dehumidifier."""

def __init__(self, data: Dict[str, Any], device_info: DeviceInfo) -> None:
"""
Response of a Air Dehumidifier (nwt.derh.wdh318efw1):
"""Response of a Air Dehumidifier (nwt.derh.wdh318efw1):

{'on_off': 'on', 'mode': 'auto', 'fan_st': 2,
'buzzer': 'off', 'led': 'on', 'child_lock': 'off',
Expand All @@ -80,7 +79,10 @@ def is_on(self) -> bool:

@property
def mode(self) -> OperationMode:
"""Operation mode. Can be either on, auth or dry_cloth."""
"""Operation mode.

Can be either on, auth or dry_cloth.
"""
return OperationMode(self.data["mode"])

@property
Expand Down Expand Up @@ -112,7 +114,10 @@ def child_lock(self) -> bool:

@property
def target_humidity(self) -> Optional[int]:
"""Target humiditiy. Can be either 40, 50, 60 percent."""
"""Target humiditiy.

Can be either 40, 50, 60 percent.
"""
if "auto" in self.data and self.data["auto"] is not None:
return self.data["auto"]
return None
Expand Down
3 changes: 1 addition & 2 deletions miio/airfilter_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ class FilterTypeUtil:
def determine_filter_type(
self, rfid_tag: Optional[str], product_id: Optional[str]
) -> Optional[FilterType]:
"""
Determine Xiaomi air filter type based on its product ID.
"""Determine Xiaomi air filter type based on its product ID.

:param rfid_tag: RFID tag value
:param product_id: Product ID such as "0:0:30:33"
Expand Down
5 changes: 4 additions & 1 deletion miio/airfresh_t2017.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,10 @@ def set_ptc_timer(self):

@command()
def get_ptc_timer(self):
"""Returns a list of PTC timers. Response unknown."""
"""Returns a list of PTC timers.

Response unknown.
"""
return self.send("get_ptc_timer")

@command()
Expand Down
25 changes: 16 additions & 9 deletions miio/airhumidifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ class AirHumidifierStatus:
"""Container for status reports from the air humidifier."""

def __init__(self, data: Dict[str, Any], device_info: DeviceInfo) -> None:
"""
Response of a Air Humidifier (zhimi.humidifier.v1):
"""Response of a Air Humidifier (zhimi.humidifier.v1):

{'power': 'off', 'mode': 'high', 'temp_dec': 294,
'humidity': 33, 'buzzer': 'on', 'led_b': 0,
Expand All @@ -84,7 +83,10 @@ def is_on(self) -> bool:

@property
def mode(self) -> OperationMode:
"""Operation mode. Can be either silent, medium or high."""
"""Operation mode.

Can be either silent, medium or high.
"""
return OperationMode(self.data["mode"])

@property
Expand Down Expand Up @@ -120,13 +122,15 @@ def child_lock(self) -> bool:

@property
def target_humidity(self) -> int:
"""Target humidity. Can be either 30, 40, 50, 60, 70, 80 percent."""
"""Target humidity.

Can be either 30, 40, 50, 60, 70, 80 percent.
"""
return self.data["limit_hum"]

@property
def trans_level(self) -> Optional[int]:
"""
The meaning of the property is unknown.
"""The meaning of the property is unknown.

The property is used to determine the strong mode is enabled on old firmware.
"""
Expand All @@ -147,7 +151,10 @@ def strong_mode_enabled(self) -> bool:

@property
def firmware_version(self) -> str:
"""Returns the fw_ver of miIO.info. For example 1.2.9_5033."""
"""Returns the fw_ver of miIO.info.

For example 1.2.9_5033.
"""
return self.device_info.firmware_version

@property
Expand Down Expand Up @@ -179,8 +186,8 @@ def depth(self) -> Optional[int]:

@property
def dry(self) -> Optional[bool]:
"""
Dry mode: The amount of water is not enough to continue to work for about 8 hours.
"""Dry mode: The amount of water is not enough to continue to work for about 8
hours.

Return True if dry mode is on if available.
"""
Expand Down
13 changes: 7 additions & 6 deletions miio/airhumidifier_jsq.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class AirHumidifierStatus:
"""Container for status reports from the air humidifier jsq."""

def __init__(self, data: Dict[str, Any]) -> None:
"""
Status of an Air Humidifier (shuii.humidifier.jsq001):
"""Status of an Air Humidifier (shuii.humidifier.jsq001):

[24, 30, 1, 1, 0, 2, 0, 0, 0]

Parsed by AirHumidifierJsq device as:
Expand All @@ -70,7 +70,10 @@ def is_on(self) -> bool:

@property
def mode(self) -> OperationMode:
"""Operation mode. Can be either low, medium, high or humidity."""
"""Operation mode.

Can be either low, medium, high or humidity.
"""

try:
mode = OperationMode(self.data["mode"])
Expand Down Expand Up @@ -153,9 +156,7 @@ def __repr__(self) -> str:


class AirHumidifierJsq(Device):
"""
Implementation of Xiaomi Zero Fog Humidifier: shuii.humidifier.jsq001
"""
"""Implementation of Xiaomi Zero Fog Humidifier: shuii.humidifier.jsq001."""

def __init__(
self,
Expand Down
8 changes: 5 additions & 3 deletions miio/airhumidifier_mjjsq.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ class AirHumidifierStatus:
"""Container for status reports from the air humidifier mjjsq."""

def __init__(self, data: Dict[str, Any]) -> None:
"""
Response of a Air Humidifier (deerma.humidifier.mjjsq):
"""Response of a Air Humidifier (deerma.humidifier.mjjsq):

{'Humidifier_Gear': 4, 'Humidity_Value': 44, 'HumiSet_Value': 54,
'Led_State': 1, 'OnOff_State': 0, 'TemperatureValue': 21,
Expand All @@ -71,7 +70,10 @@ def is_on(self) -> bool:

@property
def mode(self) -> OperationMode:
"""Operation mode. Can be either low, medium, high or humidity."""
"""Operation mode.

Can be either low, medium, high or humidity.
"""
return OperationMode(self.data["Humidifier_Gear"])

@property
Expand Down
17 changes: 12 additions & 5 deletions miio/airpurifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ class AirPurifierStatus:
_filter_type_cache = {}

def __init__(self, data: Dict[str, Any]) -> None:
"""
Response of a Air Purifier Pro (zhimi.airpurifier.v6):
"""Response of a Air Purifier Pro (zhimi.airpurifier.v6):

{'power': 'off', 'aqi': 7, 'average_aqi': 18, 'humidity': 45,
'temp_dec': 234, 'mode': 'auto', 'favorite_level': 17,
Expand Down Expand Up @@ -131,7 +130,10 @@ def mode(self) -> OperationMode:

@property
def sleep_mode(self) -> Optional[SleepMode]:
"""Operation mode of the sleep state. (Idle vs. Silent)"""
"""Operation mode of the sleep state.

(Idle vs. Silent)
"""
if self.data["sleep_mode"] is not None:
return SleepMode(self.data["sleep_mode"])

Expand All @@ -156,7 +158,9 @@ def led_brightness(self) -> Optional[LedBrightness]:
@property
def illuminance(self) -> Optional[int]:
"""Environment illuminance level in lux [0-200].
Sensor value is updated only when device is turned on."""

Sensor value is updated only when device is turned on.
"""
return self.data["bright"]

@property
Expand Down Expand Up @@ -525,7 +529,10 @@ def set_learn_mode(self, learn_mode: bool):
),
)
def set_auto_detect(self, auto_detect: bool):
"""Set auto detect on/off. It's a feature of the AirPurifier V1 & V3"""
"""Set auto detect on/off.

It's a feature of the AirPurifier V1 & V3
"""
if auto_detect:
return self.send("set_act_det", ["on"])
else:
Expand Down
8 changes: 5 additions & 3 deletions miio/airpurifier_airdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ class AirDogStatus:
"""Container for status reports from the air dog x3."""

def __init__(self, data: Dict[str, Any]) -> None:
"""
Response of a Air Dog X3 (airdog.airpurifier.x3):
"""Response of a Air Dog X3 (airdog.airpurifier.x3):

{'power: 'on', 'mode': 'sleep', 'speed': 1, 'lock': 'unlock',
'clean': 'n', 'pm': 11, 'hcho': 0}
Expand All @@ -65,7 +64,10 @@ def is_on(self) -> bool:

@property
def mode(self) -> OperationMode:
"""Operation mode. Can be either auto, manual, sleep."""
"""Operation mode.

Can be either auto, manual, sleep.
"""
return OperationMode(self.data["mode"])

@property
Expand Down
5 changes: 2 additions & 3 deletions miio/airpurifier_miot.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,8 @@ def set_mode(self, mode: OperationMode):
default_output=format_output("Setting favorite level to {level}"),
)
def set_favorite_level(self, level: int):
"""Set the favorite level used when the mode is `favorite`,
should be between 0 and 14.
"""
"""Set the favorite level used when the mode is `favorite`, should be between 0
and 14."""
if level < 0 or level > 14:
raise AirPurifierMiotException("Invalid favorite level: %s" % level)

Expand Down
Loading