From c30ff1d9639e16803b3884af6cfb1aefb180984c Mon Sep 17 00:00:00 2001 From: Albert Villanova del Moral <8515462+albertvillanova@users.noreply.github.com> Date: Mon, 31 Jul 2023 06:59:50 +0200 Subject: [PATCH] Fix deprecation of use_auth_token in DownloadConfig (#6094) Fix deprecated use_auth_token in DownloadConfig --- src/datasets/download/download_config.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/datasets/download/download_config.py b/src/datasets/download/download_config.py index f2e8c032b28..27603f4953a 100644 --- a/src/datasets/download/download_config.py +++ b/src/datasets/download/download_config.py @@ -1,6 +1,6 @@ import copy import warnings -from dataclasses import dataclass, field +from dataclasses import InitVar, dataclass, field from pathlib import Path from typing import Any, Dict, Optional, Union @@ -74,19 +74,19 @@ class DownloadConfig: num_proc: Optional[int] = None max_retries: int = 1 token: Optional[Union[str, bool]] = None - use_auth_token = "deprecated" + use_auth_token: InitVar[Optional[Union[str, bool]]] = "deprecated" ignore_url_params: bool = False storage_options: Dict[str, Any] = field(default_factory=dict) download_desc: Optional[str] = None - def __post_init__(self): - if self.use_auth_token != "deprecated": + def __post_init__(self, use_auth_token): + if use_auth_token != "deprecated": warnings.warn( "'use_auth_token' was deprecated in favor of 'token' in version 2.14.0 and will be removed in 3.0.0.\n" - f"You can remove this warning by passing 'token={self.use_auth_token}' instead.", + f"You can remove this warning by passing 'token={use_auth_token}' instead.", FutureWarning, ) - self.token = self.use_auth_token + self.token = use_auth_token if "hf" not in self.storage_options: self.storage_options["hf"] = {"token": self.token, "endpoint": config.HF_ENDPOINT}