Skip to content

Commit

Permalink
chore(pre-commit.ci): pre-commit autoupdate (#195)
Browse files Browse the repository at this point in the history
<!--pre-commit.ci start-->
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.4.10 →
v0.5.0](astral-sh/ruff-pre-commit@v0.4.10...v0.5.0)
<!--pre-commit.ci end-->

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
  • Loading branch information
pre-commit-ci[bot] and chemelli74 authored Jul 2, 2024
1 parent d5db805 commit 71b0900
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
- id: no-commit-to-branch
args: ["--branch", "main"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.10
rev: v0.5.0
hooks:
- id: ruff
args:
Expand Down
5 changes: 1 addition & 4 deletions midealocal/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,7 @@ async def get_keys(self, appliance_id: int) -> dict[int, dict[str, Any]]:
@staticmethod
async def get_cloud_servers() -> dict[int, str]:
"""Get available cloud servers."""
cloud_servers: dict[int, str] = {}
for i, cloud in enumerate(clouds, start=1):
cloud_servers[i] = cloud
return cloud_servers
return {i: cloud for i, cloud in enumerate(clouds, start=1)}

async def list_home(self) -> dict[int, Any] | None:
"""List homes."""
Expand Down
4 changes: 1 addition & 3 deletions midealocal/devices/a1/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,7 @@ def __init__(self, body: bytearray) -> None:
self.power = (body[1] & 0x01) > 0
self.mode = body[2] & 0x0F
self.fan_speed = body[3] & 0x7F
self.target_humidity = (
MIN_TARGET_HUMIDITY if (body[7] < MIN_TARGET_HUMIDITY) else body[7]
)
self.target_humidity = max(body[7], MIN_TARGET_HUMIDITY)
self.child_lock = (body[8] & 0x80) > 0
self.anion = (body[9] & 0x40) > 0
self.tank = body[10] & 0x7F
Expand Down
2 changes: 1 addition & 1 deletion midealocal/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def encrypt_iam_password(self, login_id: str, data: str) -> str:
@staticmethod
def get_deviceid(username: str) -> str:
"""Get device ID."""
return sha256(f"Hello, {username}!".encode("ascii")).digest().hex()[:16]
return sha256(f"Hello, {username}!".encode("ascii")).hexdigest()[:16]

@staticmethod
def get_udp_id(appliance_id: int, method: int = 0) -> str | None:
Expand Down
19 changes: 19 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,37 @@ target-version = "py311"

lint.select = ["ALL"]

lint.preview = true

lint.ignore = [
"ANN101", # Missing type annotation for `self` in method
"B909", # Mutation to loop iterable `self._attributes` during iteration
"C416", # Unnecessary `dict` comprehension (rewrite using `dict()`)
"CPY001", # Missing copyright notice at top of file
"D203", # 1 blank line required before class docstring
"D213", # Multi-line docstring summary should start at the second line
"EM101", # Exception must not use a string literal, assign to variable first
"EM102", # Exception must not use an f-string literal, assign to variable first
"FBT001", # Boolean-typed positional argument in function definition
"FBT002", # Boolean default positional argument in function definition
"FBT003", # Boolean positional value in function call
"FURB110", # Replace ternary `if` expression with `or` operator
"FURB116", # Replace `hex` call with f-string
"FURB118", # Use `operator.itemgetter(0)` instead of defining a lambda
"N818", # Exception name should be named with an Error suffix
"PLC1901", # can be simplified as an empty string is falsey
"PLR0904", # Too many public methods
"PLR0912", # Too many branches
"PLR0913", # Too many arguments in function definition
"PLR0914", # Too many local variables
"PLR0916", # Too many Boolean expressions
"PLR0917", # Too many positional arguments
"PLR1702", # Too many nested blocks
"PLR6104", # Use `+=` to perform an augmented assignment directly
"PLR6201", # Use a `set` literal when testing for membership
"PLR6301", # Method could be a function, class method, or static method
"RUF021", # Parenthesize expressions when chaining `and` and `or` together, to make the precedence clear
"S413", # `pycrypto` library is known to have publicly disclosed buffer overflow vulnerability
"TRY003", # Avoid specifying long messages outside the exception class
]

Expand Down

0 comments on commit 71b0900

Please sign in to comment.