Skip to content

Update session.py #318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tidalapi/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,12 +633,12 @@ def save_session_to_file(self, session_file: Path):
"is_pkce": {"data": self.is_pkce},
# "expiry_time": {"data": self.expiry_time},
}
with session_file.open("w") as outfile:
with open(session_file, "w") as outfile:
Copy link
Contributor

@C0rn3j C0rn3j Apr 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

session_file is declared to be a Path object, what's the point of reverting it to the plain open()?

If anything, rest of the code should be converted to Path.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If anything, rest of the code should be converted to Path.

Agreed

json.dump(data, outfile)

def load_session_from_file(self, session_file: Path):
try:
with open(session_file) as f:
with open(session_file, "r") as f:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this is redundant and linters will scream at you for it:

https://docs.python.org/3/library/functions.html#open

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change does not make sense, IMO. We should make use of the Path object and call .open() on it.

log.info("Loading session from %s...", session_file)
data = json.load(f)
except Exception as e:
Expand Down