diff --git a/pyproject.toml b/pyproject.toml index 3c89578..1892a19 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,6 +56,7 @@ line-length = 110 ignore = [ "F403", "F405", "F821", "E731" ] extend-select = [ "I", # isort + "UP", # pyupgrade ] [tool.mypy] diff --git a/tests/auth/test_oauth.py b/tests/auth/test_oauth.py index ea12e54..1519a97 100644 --- a/tests/auth/test_oauth.py +++ b/tests/auth/test_oauth.py @@ -53,7 +53,7 @@ class TestOAuth: assert Path(oauth_filepath).exists() json_mock.side_effect = None - with open(oauth_filepath, mode="r", encoding="utf8") as oauth_file: + with open(oauth_filepath, encoding="utf8") as oauth_file: oauth_token = json.loads(oauth_file.read()) assert oauth_token["expires_at"] != 0 @@ -67,7 +67,7 @@ class TestOAuth: assert yt_oauth._token is not None # set reference file - with open(oauth_filepath, "r") as f: + with open(oauth_filepath) as f: first_json = json.load(f) # pull reference values from underlying token @@ -89,7 +89,7 @@ class TestOAuth: # check token is propagating properly assert second_token == second_token_inner - with open(oauth_filepath, "r") as f2: + with open(oauth_filepath) as f2: second_json = json.load(f2) # ensure token is updating local file @@ -100,7 +100,7 @@ class TestOAuth: ): # ensure client works/ignores alt if browser credentials passed as auth assert yt_alt_oauth.auth_type != AuthType.OAUTH_CUSTOM_CLIENT - with open(oauth_filepath, "r") as f: + with open(oauth_filepath) as f: token_dict = json.load(f) # oauth token dict entry and alt yt_alt_oauth = YTMusic(token_dict, oauth_credentials=alt_oauth_credentials) diff --git a/ytmusicapi/mixins/browsing.py b/ytmusicapi/mixins/browsing.py index 0d4526b..151d95d 100644 --- a/ytmusicapi/mixins/browsing.py +++ b/ytmusicapi/mixins/browsing.py @@ -884,7 +884,7 @@ class BrowsingMixin(MixinProtocol): for artist in artists: if artist not in taste_profile: - raise Exception("The artist, {}, was not present in taste!".format(artist)) + raise Exception(f"The artist, {artist}, was not present in taste!") formData["selectedValues"].append(taste_profile[artist]["selectionValue"]) body = {"browseId": "FEmusic_home", "formData": formData} diff --git a/ytmusicapi/mixins/library.py b/ytmusicapi/mixins/library.py index bde3b7a..d66f699 100644 --- a/ytmusicapi/mixins/library.py +++ b/ytmusicapi/mixins/library.py @@ -234,7 +234,7 @@ class LibraryMixin(MixinProtocol): """ url = song["playbackTracking"]["videostatsPlaybackUrl"]["baseUrl"] CPNA = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_" - cpn = "".join((CPNA[randint(0, 256) & 63] for _ in range(0, 16))) + cpn = "".join(CPNA[randint(0, 256) & 63] for _ in range(0, 16)) params = {"ver": 2, "c": "WEB_REMIX", "cpn": cpn} return self._send_get_request(url, params)