Skip to content
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

Extract username from session #290

Merged
merged 4 commits into from
Jan 6, 2019
Merged

Conversation

jacebrowning
Copy link
Contributor

Fixes #274

@codecov
Copy link

codecov bot commented Jan 5, 2019

Codecov Report

Merging #290 into master will decrease coverage by 0.3%.
The diff coverage is 37.5%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #290      +/-   ##
==========================================
- Coverage   95.39%   95.08%   -0.31%     
==========================================
  Files           2        2              
  Lines        1215     1220       +5     
==========================================
+ Hits         1159     1160       +1     
- Misses         56       60       +4
Impacted Files Coverage Δ
pylast/__init__.py 95.07% <37.5%> (-0.31%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6134945...fffc647. Read the comment docs.

@jacebrowning
Copy link
Contributor Author

@hugovk With this change, my application is now able to use the old behavior:

 network = pylast.LastFMNetwork(
    api_key=settings.LASTFM_API_KEY,
    api_secret=settings.LASTFM_API_SECRET,
    token=token,
)
user = network.get_authenticated_user()
username = user.get_name()
print(username)

Any feedback on this implementation?

@hugovk
Copy link
Member

hugovk commented Jan 5, 2019

Thanks for the PR!


First of all, this changes the public API.

get_web_auth_session_key used to return a single session_key value, but now returns a session_key, username tuple.

There's quite a bit of existing third-party code out there that is expecting a single value, and this would break that code.

How about adding a new method, something like this?

    def get_web_auth_session_key_and_username(self, url, token=""):
        # as get_web_auth_session_key is now in the PR
        # ...
        return session_key, username

    def get_web_auth_session_key(self, url, token=""):
        session_key, username = get_web_auth_session_key_and_username(url, token)
        return session_key

Then the existing code out there can still call get_web_auth_session_key.


Please could you also fix the lint formatting check? You can do it automatically with:

pip install black
black .

setup.cfg Outdated Show resolved Hide resolved
@hugovk
Copy link
Member

hugovk commented Jan 6, 2019

Thank you!

@hugovk hugovk merged commit d121f2c into pylast:master Jan 6, 2019
hugovk added a commit that referenced this pull request Jan 6, 2019
@hugovk
Copy link
Member

hugovk commented Mar 7, 2019

This had been released in pylast 3.1.0. Thanks again!

@jacebrowning jacebrowning deleted the fix-blank-username branch March 7, 2019 17:47
@Qwerty-Space
Copy link

This had been released in pylast 3.1.0. Thanks again!

@hugovk I'm still having this issue in 3.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants