Skip to content

Commit f67fad9

Browse files
[Internal] Fix ty quality (#3441)
* fix ty quality * ignore possibly-missing-attribute * fix * imports * fix * type discussion event common args * Update src/huggingface_hub/_webhooks_server.py Co-authored-by: Lucain <lucain@huggingface.co> --------- Co-authored-by: Lucain Pouget <lucainp@gmail.com> Co-authored-by: Lucain <lucain@huggingface.co>
1 parent a6114b9 commit f67fad9

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ unresolved-attribute = "ignore"
1414

1515
# Be tolerant with framework/typing edge-cases and runtime-validated code paths
1616
unsupported-base = "ignore"
17-
possibly-unbound-attribute = "ignore"
1817
unsupported-operator = "ignore"
18+
possibly-missing-attribute = "ignore"
19+
possibly-missing-implicit-call = "ignore"
1920
non-subscriptable = "ignore"
2021
call-non-callable = "ignore"
2122

src/huggingface_hub/_webhooks_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from fastapi.responses import JSONResponse
3333
else:
3434
# Will fail at runtime if FastAPI is not available
35-
FastAPI = Request = JSONResponse = None # type: ignore [misc, assignment]
35+
FastAPI = Request = JSONResponse = None # type: ignore
3636

3737

3838
_global_app: Optional["WebhooksServer"] = None

src/huggingface_hub/community.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from dataclasses import dataclass
99
from datetime import datetime
10-
from typing import List, Literal, Optional, Union
10+
from typing import List, Literal, Optional, TypedDict, Union
1111

1212
from . import constants
1313
from .utils import parse_datetime
@@ -143,6 +143,14 @@ class DiscussionWithDetails(Discussion):
143143
diff: Optional[str]
144144

145145

146+
class DiscussionEventArgs(TypedDict):
147+
id: str
148+
type: str
149+
created_at: datetime
150+
author: str
151+
_event: dict
152+
153+
146154
@dataclass
147155
class DiscussionEvent:
148156
"""
@@ -319,13 +327,13 @@ def deserialize_event(event: dict) -> DiscussionEvent:
319327
event_type: str = event["type"]
320328
created_at = parse_datetime(event["createdAt"])
321329

322-
common_args = dict(
323-
id=event_id,
324-
type=event_type,
325-
created_at=created_at,
326-
author=event.get("author", {}).get("name", "deleted"),
327-
_event=event,
328-
)
330+
common_args: DiscussionEventArgs = {
331+
"id": event_id,
332+
"type": event_type,
333+
"created_at": created_at,
334+
"author": event.get("author", {}).get("name", "deleted"),
335+
"_event": event,
336+
}
329337

330338
if event_type == "comment":
331339
return DiscussionComment(

src/huggingface_hub/serialization/_torch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def save_torch_state_dict(
266266
safe_file_kwargs = {"metadata": per_file_metadata} if safe_serialization else {}
267267
for filename, tensors in state_dict_split.filename_to_tensors.items():
268268
shard = {tensor: state_dict[tensor] for tensor in tensors}
269-
save_file_fn(shard, os.path.join(save_directory, filename), **safe_file_kwargs)
269+
save_file_fn(shard, os.path.join(save_directory, filename), **safe_file_kwargs) # ty: ignore[invalid-argument-type]
270270
logger.debug(f"Shard saved to {filename}")
271271

272272
# Save the index (if any)

0 commit comments

Comments
 (0)