Skip to content

Commit 5c3efe3

Browse files
authored
Update mypy to 1.15.0 (current latest) (#3095)
* Update mypy to 1.15.0 (current latest) * fix * fix * no need of these rules
1 parent a5e089c commit 5c3efe3

File tree

6 files changed

+15
-12
lines changed

6 files changed

+15
-12
lines changed

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
[tool.mypy]
22
ignore_missing_imports = true
3-
no_implicit_optional = true
4-
scripts_are_modules = true
53

64
[tool.pytest.ini_options]
75
# Add the specified `OPTS` to the set of command line arguments as if they had

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ def get_version() -> str:
106106

107107
extras["quality"] = [
108108
"ruff>=0.9.0",
109-
"mypy==1.5.1",
109+
"mypy>=1.14.1,<1.15.0; python_version=='3.8'",
110+
"mypy==1.15.0; python_version>='3.9'",
110111
"libcst==1.4.0",
111112
]
112113

src/huggingface_hub/_oauth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ async def oauth_redirect_callback(request: fastapi.Request) -> RedirectResponse:
310310
target_url = request.query_params.get("_target_url")
311311

312312
# Build redirect URI with the same query params as before and bump nb_redirects count
313-
query_params: dict[str, Union[int, str]] = {"_nb_redirects": nb_redirects + 1}
313+
query_params: Dict[str, Union[int, str]] = {"_nb_redirects": nb_redirects + 1}
314314
if target_url:
315315
query_params["_target_url"] = target_url
316316

src/huggingface_hub/dataclasses.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ def validated_field(
269269
metadata = {}
270270
metadata["validator"] = validator
271271
return field( # type: ignore
272-
default=default,
273-
default_factory=default_factory,
272+
default=default, # type: ignore [arg-type]
273+
default_factory=default_factory, # type: ignore [arg-type]
274274
init=init,
275275
repr=repr,
276276
hash=hash,

src/huggingface_hub/hub_mixin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def _is_jsonable(cls, value: Any) -> bool:
353353
def _encode_arg(cls, arg: Any) -> Any:
354354
"""Encode an argument into a JSON serializable format."""
355355
if is_dataclass(arg):
356-
return asdict(arg)
356+
return asdict(arg) # type: ignore[arg-type]
357357
for type_, (encoder, _) in cls._hub_mixin_coders.items():
358358
if isinstance(arg, type_):
359359
if arg is None:
@@ -767,7 +767,7 @@ def __init_subclass__(cls, *args, tags: Optional[List[str]] = None, **kwargs) ->
767767
def _save_pretrained(self, save_directory: Path) -> None:
768768
"""Save weights from a Pytorch model to a local directory."""
769769
model_to_save = self.module if hasattr(self, "module") else self # type: ignore
770-
save_model_as_safetensor(model_to_save, str(save_directory / constants.SAFETENSORS_SINGLE_FILE))
770+
save_model_as_safetensor(model_to_save, str(save_directory / constants.SAFETENSORS_SINGLE_FILE)) # type: ignore [arg-type]
771771

772772
@classmethod
773773
def _from_pretrained(

src/huggingface_hub/utils/insecure_hashlib.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@
2828
import sys
2929

3030

31-
_kwargs = {"usedforsecurity": False} if sys.version_info >= (3, 9) else {}
32-
md5 = functools.partial(hashlib.md5, **_kwargs)
33-
sha1 = functools.partial(hashlib.sha1, **_kwargs)
34-
sha256 = functools.partial(hashlib.sha256, **_kwargs)
31+
if sys.version_info >= (3, 9):
32+
md5 = functools.partial(hashlib.md5, usedforsecurity=False)
33+
sha1 = functools.partial(hashlib.sha1, usedforsecurity=False)
34+
sha256 = functools.partial(hashlib.sha256, usedforsecurity=False)
35+
else:
36+
md5 = hashlib.md5
37+
sha1 = hashlib.sha1
38+
sha256 = hashlib.sha256

0 commit comments

Comments
 (0)