Skip to content

Commit 50e1ff5

Browse files
authored
Enable ruff PYI rule (type annotation improvements) (#2003)
## Summary - Use `Self` return type for `__aenter__` (PYI034) - Simplify `int | float` to `float` in type hints (PYI041) ## Test plan - [x] `ruff check .` passes - [x] `pytest` — 280 tests pass - [x] `mypy` passes
1 parent 4650dbd commit 50e1ff5

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

pyoverkiz/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import urllib.parse
88
from pathlib import Path
99
from types import TracebackType
10-
from typing import Any, cast
10+
from typing import Any, Self, cast
1111

1212
import backoff
1313
from aiohttp import (
@@ -216,7 +216,7 @@ def __init__(
216216
ssl_context=self._ssl,
217217
)
218218

219-
async def __aenter__(self) -> OverkizClient:
219+
async def __aenter__(self) -> Self:
220220
"""Enter async context manager and return the client instance."""
221221
return self
222222

pyoverkiz/models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,16 +1265,16 @@ class ValuePrototype:
12651265
"""Value prototype defining parameter/state value constraints."""
12661266

12671267
type: str
1268-
min_value: int | float | None = None
1269-
max_value: int | float | None = None
1268+
min_value: float | None = None
1269+
max_value: float | None = None
12701270
enum_values: list[str] | None = None
12711271
description: str | None = None
12721272

12731273
def __init__(
12741274
self,
12751275
type: str,
1276-
min_value: int | float | None = None,
1277-
max_value: int | float | None = None,
1276+
min_value: float | None = None,
1277+
max_value: float | None = None,
12781278
enum_values: list[str] | None = None,
12791279
description: str | None = None,
12801280
**_: Any,

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ select = [
116116
"PIE",
117117
# eradicate
118118
"ERA",
119+
# flake8-pyi
120+
"PYI",
119121
]
120122
ignore = [
121123
"E501", # Line too long

0 commit comments

Comments
 (0)