From b1b9f5fde98d52501f20af53da1dfa77abbabcad Mon Sep 17 00:00:00 2001 From: Simon Alibert Date: Mon, 6 Jan 2025 10:34:10 +0100 Subject: [PATCH] Add suggestion from code review --- src/huggingface_hub/hub_mixin.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/huggingface_hub/hub_mixin.py b/src/huggingface_hub/hub_mixin.py index d2da195014..36b350394f 100644 --- a/src/huggingface_hub/hub_mixin.py +++ b/src/huggingface_hub/hub_mixin.py @@ -3,7 +3,7 @@ import os from dataclasses import Field, asdict, dataclass, is_dataclass from pathlib import Path -from typing import TYPE_CHECKING, Any, Callable, ClassVar, Dict, List, Optional, Protocol, Tuple, Type, TypeVar, Union +from typing import Any, Callable, ClassVar, Dict, List, Optional, Protocol, Tuple, Type, TypeVar, Union import packaging.version @@ -24,12 +24,9 @@ ) -if TYPE_CHECKING: - from _typeshed import DataclassInstance # type: ignore -else: - - class DataclassInstance(Protocol): # type: ignore - __dataclass_fields__: ClassVar[Dict[str, Field]] +# Type alias for dataclass instances +class DataclassInstance(Protocol): + __dataclass_fields__: ClassVar[dict[str, Field[Any]]] Dataclass = TypeVar("Dataclass", bound=DataclassInstance)