From c86e31731986469a6263ae483acd7e5fe6b84f79 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 08:14:15 +0545 Subject: [PATCH] chore(deps): update dependency dev/mypy to v1.10.0 (#165) * chore(deps): update dependency dev/mypy to v1.10.0 * chore(mypy): cleanup types, remove ignores --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Ivan Shcheklein --- pyproject.toml | 2 +- src/dvc_studio_client/auth.py | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 86e34b0..4e4f062 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,7 +45,7 @@ tests = [ dev = [ "dvc-studio-client[tests,docs]", "types-requests", - "mypy==1.9.0" + "mypy==1.10.0" ] [tool.setuptools_scm] diff --git a/src/dvc_studio_client/auth.py b/src/dvc_studio_client/auth.py index 8f8ebf8..bd92aac 100644 --- a/src/dvc_studio_client/auth.py +++ b/src/dvc_studio_client/auth.py @@ -1,5 +1,5 @@ import sys -from typing import Optional, TypedDict +from typing import Optional, TypedDict, Union from urllib.parse import urljoin import requests @@ -136,20 +136,22 @@ def start_device_login( "Starting device login for Studio%s", f" ({base_url})" if base_url else "", ) - if invalid_scopes := list( - filter(lambda s: s.upper() not in AVAILABLE_SCOPES, scopes), # type: ignore[arg-type,attr-defined] - ): - raise InvalidScopesError( # noqa: TRY003 - f"Following scopes are not valid: {', '.join(invalid_scopes)}", # type: ignore[arg-type] - ) + if scopes: + invalid_scopes: list[str] + if invalid_scopes := list( + filter(lambda s: s.upper() not in AVAILABLE_SCOPES, scopes), + ): + raise InvalidScopesError( # noqa: TRY003 + f"Following scopes are not valid: {', '.join(invalid_scopes)}", + ) - body = {"client_name": client_name} + body: dict[str, Union[str, list[str]]] = {"client_name": client_name} if token_name: body["token_name"] = token_name if scopes: - body["scopes"] = scopes # type: ignore[assignment] + body["scopes"] = scopes logger.debug(f"JSON body `{body=}`")