Skip to content

Commit 03a0484

Browse files
adamtheturtleclaude
andcommitted
Use the pyrefly strict preset
The strict preset enables unused-ignore along with implicit-any, missing-override-decorator and other checks. Fix the new errors: add @OverRide decorators, replace an untyped lambda sort key with a typed function, and type two empty containers. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 16787e6 commit 03a0484

5 files changed

Lines changed: 23 additions & 9 deletions

File tree

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ search_path = [
454454
"src",
455455
]
456456
errors.non-exhaustive-match = "error"
457-
errors.unused-ignore = "error"
457+
preset = "strict"
458458

459459
[tool.pyright]
460460
typeCheckingMode = "strict"

‎src/mock_vws/_httpx2_mock_server/decorators.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import re
1111
from collections.abc import Callable, Mapping, Sequence
1212
from dataclasses import dataclass
13-
from typing import Protocol
13+
from typing import Protocol, override
1414
from unittest import mock
1515
from urllib.parse import urlparse
1616

@@ -173,6 +173,7 @@ def __init__(
173173
self._fakes = fakes
174174
self._wrapped = wrapped
175175

176+
@override
176177
def handle_request(self, request: httpx2.Request) -> httpx2.Response:
177178
"""Handle a request from a synchronous ``httpx2`` client.
178179
@@ -217,6 +218,7 @@ def __init__(
217218
self._fakes = fakes
218219
self._wrapped = wrapped
219220

221+
@override
220222
async def handle_async_request(
221223
self,
222224
request: httpx2.Request,

‎src/mock_vws/_mock_common.py‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
"""Common utilities for creating mock routes."""
22

3+
import datetime
34
import email.utils
45
import json
56
import uuid
67
from collections.abc import Iterable, Mapping
78
from dataclasses import dataclass
8-
from typing import Any
9+
from typing import Any, override
910

1011
from beartype import beartype
1112

@@ -34,6 +35,7 @@ def __init__(self, url: str) -> None:
3435
super().__init__()
3536
self.url = url
3637

38+
@override
3739
def __str__(self) -> str:
3840
"""
3941
Give a string representation of this error with a
@@ -80,6 +82,19 @@ class Route:
8082
http_methods: Iterable[str]
8183

8284

85+
@beartype
86+
def _upload_order_key(target: ImageTarget) -> tuple[datetime.datetime, str]:
87+
"""Give the sort key which orders targets by upload date, then ID.
88+
89+
Args:
90+
target: The target to give a sort key for.
91+
92+
Returns:
93+
The target's upload date and ID.
94+
"""
95+
return (target.upload_date, target.target_id)
96+
97+
8398
@beartype
8499
def sorted_targets(*, targets: Iterable[ImageTarget]) -> list[ImageTarget]:
85100
"""Put targets into a deterministic order.
@@ -94,10 +109,7 @@ def sorted_targets(*, targets: Iterable[ImageTarget]) -> list[ImageTarget]:
94109
Returns:
95110
The given targets, ordered by upload date and then by target ID.
96111
"""
97-
return sorted(
98-
targets,
99-
key=lambda target: (target.upload_date, target.target_id),
100-
)
112+
return sorted(targets, key=_upload_order_key)
101113

102114

103115
@beartype

‎src/mock_vws/_model_target_web_api.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,7 @@ def _validate_dataset_request(
13351335
for model in models:
13361336
if isinstance(model.get("views"), list):
13371337
model["views"] = [
1338-
view if isinstance(view, dict) else {}
1338+
view if isinstance(view, dict) else dict[str, Any]()
13391339
for view in model["views"]
13401340
]
13411341
details = (

‎tests/mock_vws/test_model_target_web_api.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2394,7 +2394,7 @@ def test_client_credential_authentication_errors() -> None:
23942394
"""Credential-management routes enforce bearer-token validity and
23952395
scope.
23962396
"""
2397-
headers = [
2397+
headers: list[dict[str, str]] = [
23982398
{},
23992399
{"Authorization": "Bearer malformed"},
24002400
{"Authorization": "Bearer e30.e30.signature"},

0 commit comments

Comments
 (0)