ruff: pyupgrade

This commit is contained in:
sigma67 2024-01-18 21:48:04 +01:00
commit b87c783d45
No known key found for this signature in database
GPG key ID: 1C314227DF0103D0
4 changed files with 7 additions and 6 deletions

View file

@ -56,6 +56,7 @@ line-length = 110
ignore = [ "F403", "F405", "F821", "E731" ] ignore = [ "F403", "F405", "F821", "E731" ]
extend-select = [ extend-select = [
"I", # isort "I", # isort
"UP", # pyupgrade
] ]
[tool.mypy] [tool.mypy]

View file

@ -53,7 +53,7 @@ class TestOAuth:
assert Path(oauth_filepath).exists() assert Path(oauth_filepath).exists()
json_mock.side_effect = None 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()) oauth_token = json.loads(oauth_file.read())
assert oauth_token["expires_at"] != 0 assert oauth_token["expires_at"] != 0
@ -67,7 +67,7 @@ class TestOAuth:
assert yt_oauth._token is not None assert yt_oauth._token is not None
# set reference file # set reference file
with open(oauth_filepath, "r") as f: with open(oauth_filepath) as f:
first_json = json.load(f) first_json = json.load(f)
# pull reference values from underlying token # pull reference values from underlying token
@ -89,7 +89,7 @@ class TestOAuth:
# check token is propagating properly # check token is propagating properly
assert second_token == second_token_inner assert second_token == second_token_inner
with open(oauth_filepath, "r") as f2: with open(oauth_filepath) as f2:
second_json = json.load(f2) second_json = json.load(f2)
# ensure token is updating local file # ensure token is updating local file
@ -100,7 +100,7 @@ class TestOAuth:
): ):
# ensure client works/ignores alt if browser credentials passed as auth # ensure client works/ignores alt if browser credentials passed as auth
assert yt_alt_oauth.auth_type != AuthType.OAUTH_CUSTOM_CLIENT 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) token_dict = json.load(f)
# oauth token dict entry and alt # oauth token dict entry and alt
yt_alt_oauth = YTMusic(token_dict, oauth_credentials=alt_oauth_credentials) yt_alt_oauth = YTMusic(token_dict, oauth_credentials=alt_oauth_credentials)

View file

@ -884,7 +884,7 @@ class BrowsingMixin(MixinProtocol):
for artist in artists: for artist in artists:
if artist not in taste_profile: 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"]) formData["selectedValues"].append(taste_profile[artist]["selectionValue"])
body = {"browseId": "FEmusic_home", "formData": formData} body = {"browseId": "FEmusic_home", "formData": formData}

View file

@ -234,7 +234,7 @@ class LibraryMixin(MixinProtocol):
""" """
url = song["playbackTracking"]["videostatsPlaybackUrl"]["baseUrl"] url = song["playbackTracking"]["videostatsPlaybackUrl"]["baseUrl"]
CPNA = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_" 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} params = {"ver": 2, "c": "WEB_REMIX", "cpn": cpn}
return self._send_get_request(url, params) return self._send_get_request(url, params)