Skip to content

Commit

Permalink
ruff: pyupgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
sigma67 committed Jan 18, 2024
1 parent 6a3924d commit b87c783
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ line-length = 110
ignore = [ "F403", "F405", "F821", "E731" ]
extend-select = [
"I", # isort
"UP", # pyupgrade
]

[tool.mypy]
Expand Down
8 changes: 4 additions & 4 deletions tests/auth/test_oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_setup_oauth(self, session_mock, json_mock, blank_code, config):
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
Expand All @@ -67,7 +67,7 @@ def test_oauth_tokens(self, oauth_filepath: str, yt_oauth: YTMusic):
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
Expand All @@ -89,7 +89,7 @@ def test_oauth_tokens(self, oauth_filepath: str, yt_oauth: YTMusic):
# 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
Expand All @@ -100,7 +100,7 @@ def test_oauth_custom_client(
):
# 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)
Expand Down
2 changes: 1 addition & 1 deletion ytmusicapi/mixins/browsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ def set_tasteprofile(self, artists: List[str], taste_profile: Optional[Dict] = N

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}
Expand Down
2 changes: 1 addition & 1 deletion ytmusicapi/mixins/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def add_history_item(self, song):
"""
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)

Expand Down

0 comments on commit b87c783

Please sign in to comment.