From d1317cb81ebcf3b1c7a08f922ba3ca5d4aebbefa Mon Sep 17 00:00:00 2001 From: Nick Steel Date: Wed, 25 Sep 2024 02:29:46 +0100 Subject: [PATCH] ruff fixes --- src/mopidy_spotify/__init__.py | 4 ++-- src/mopidy_spotify/web.py | 6 +++--- tests/conftest.py | 1 + tests/test_backend.py | 2 +- tests/test_browse.py | 1 + tests/test_distinct.py | 1 + tests/test_images.py | 1 + tests/test_lookup.py | 1 + tests/test_playback.py | 1 + tests/test_playlists.py | 2 +- tests/test_search.py | 1 + tests/test_translator.py | 1 + tests/test_web.py | 5 +++-- 13 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/mopidy_spotify/__init__.py b/src/mopidy_spotify/__init__.py index cfd174de..b473fb6d 100644 --- a/src/mopidy_spotify/__init__.py +++ b/src/mopidy_spotify/__init__.py @@ -17,8 +17,8 @@ def get_default_config(self): def get_config_schema(self): schema = super().get_config_schema() - schema["username"] = config.Deprecated() # since 5.0 - schema["password"] = config.Deprecated() # since 5.0 + schema["username"] = config.Deprecated() # since 5.0 + schema["password"] = config.Deprecated() # since 5.0 schema["client_id"] = config.String() schema["client_secret"] = config.Secret() diff --git a/src/mopidy_spotify/web.py b/src/mopidy_spotify/web.py index c62b6a3d..9ab76c38 100644 --- a/src/mopidy_spotify/web.py +++ b/src/mopidy_spotify/web.py @@ -75,11 +75,11 @@ def token(self): try: if self._should_refresh_token(): self._refresh_token() - logger.info(f"Providing access token: {self._access_token}") - return self._access_token except OAuthTokenRefreshError as e: logger.error(e) # noqa: TRY400 return None + else: + return self._access_token def get(self, path, cache=None, *args, **kwargs): if self._authorization_failed: @@ -161,7 +161,7 @@ def _refresh_token(self): f"wrong token_type: {result.get('token_type')}" ) - self._access_token = result['access_token'] + self._access_token = result["access_token"] self._headers["Authorization"] = f"Bearer {self._access_token}" self._expires = time.time() + result.get("expires_in", float("Inf")) diff --git a/tests/conftest.py b/tests/conftest.py index 609f7b79..2c04778f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,6 +3,7 @@ import pytest from mopidy import backend as backend_api from mopidy import models + from mopidy_spotify import backend, library, utils, web diff --git a/tests/test_backend.py b/tests/test_backend.py index e0321e41..f924a126 100644 --- a/tests/test_backend.py +++ b/tests/test_backend.py @@ -1,9 +1,9 @@ from unittest import mock, skip from mopidy import backend as backend_api + from mopidy_spotify import backend, library, playlists from mopidy_spotify.backend import SpotifyPlaybackProvider - from tests import ThreadJoiner diff --git a/tests/test_browse.py b/tests/test_browse.py index 6af4165a..65e3b21c 100644 --- a/tests/test_browse.py +++ b/tests/test_browse.py @@ -2,6 +2,7 @@ import pytest from mopidy import models + from mopidy_spotify.browse import BROWSE_DIR_URIS diff --git a/tests/test_distinct.py b/tests/test_distinct.py index 4501e0e4..a549e42d 100644 --- a/tests/test_distinct.py +++ b/tests/test_distinct.py @@ -2,6 +2,7 @@ import pytest from mopidy import models + from mopidy_spotify import distinct, playlists, search diff --git a/tests/test_images.py b/tests/test_images.py index 93921116..6d0e3309 100644 --- a/tests/test_images.py +++ b/tests/test_images.py @@ -1,5 +1,6 @@ import pytest from mopidy import models + from mopidy_spotify import images from mopidy_spotify.web import LinkType, WebLink diff --git a/tests/test_lookup.py b/tests/test_lookup.py index 24f8731a..2af1748f 100644 --- a/tests/test_lookup.py +++ b/tests/test_lookup.py @@ -3,6 +3,7 @@ import mopidy import pytest + from mopidy_spotify import lookup diff --git a/tests/test_playback.py b/tests/test_playback.py index db667213..3c0dff11 100644 --- a/tests/test_playback.py +++ b/tests/test_playback.py @@ -3,6 +3,7 @@ import pytest from mopidy import audio from mopidy import backend as backend_api + from mopidy_spotify import backend, web diff --git a/tests/test_playlists.py b/tests/test_playlists.py index 11afd383..b8709596 100644 --- a/tests/test_playlists.py +++ b/tests/test_playlists.py @@ -4,8 +4,8 @@ import pytest from mopidy import backend as backend_api from mopidy.models import Ref -from mopidy_spotify import playlists +from mopidy_spotify import playlists from tests import ThreadJoiner diff --git a/tests/test_search.py b/tests/test_search.py index a30d2b13..3ed9abe8 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -1,6 +1,7 @@ from unittest import mock from mopidy import models + from mopidy_spotify import lookup, search, translator diff --git a/tests/test_translator.py b/tests/test_translator.py index 7724c578..0b1a2abe 100644 --- a/tests/test_translator.py +++ b/tests/test_translator.py @@ -3,6 +3,7 @@ import pytest from mopidy import models + from mopidy_spotify import translator diff --git a/tests/test_web.py b/tests/test_web.py index 1dba2cad..7c7f7568 100644 --- a/tests/test_web.py +++ b/tests/test_web.py @@ -2,13 +2,14 @@ from datetime import UTC, datetime from unittest import mock -import mopidy_spotify import pytest import requests import responses -from mopidy_spotify import web from responses import matchers +import mopidy_spotify +from mopidy_spotify import web + @pytest.fixture() def oauth_client(config):