Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Add Python 3 compatibility #396

Closed
wants to merge 10 commits into from
Closed

Add Python 3 compatibility #396

wants to merge 10 commits into from

Conversation

tjstum
Copy link
Contributor

@tjstum tjstum commented Jan 10, 2016

OK, here it is.

17:25:17|stum:[~/gmusicapi] (python3-stage2 *%>)$ tox
...
________________________________________________ summary _________________________________________________
  py27: commands succeeded
  py34: commands succeeded
  py35: commands succeeded
  congratulations :)

The tests work. The example script works. I wasn't able to run the All-Access tests, so if you could help out with that, I'd appreciate it (I'll give it a shot in my application, though).

Please take a look at what I did in setup.py for protobuf. The 3.0.0b2 seems to be working fine, and since this whole thing is a bit experimental to begin with, it seemed OK. I'm happy to do something else, though.

This will need a new release of gpsoauth, with the Python 3 compatibility. I've been manually installing it in each tox environment for now.

I think I incorporated everything from last time, so please let me know what else you'd like me to tackle. Thanks for your patience

@simon-weber
Copy link
Owner

Nice work! Looks like a s/#noqa/# noqa/ will fix most of the linting errors.

It'll take me some time look over the changes, but I should be able to get to it in the next day or two.

@tjstum
Copy link
Contributor Author

tjstum commented Jan 12, 2016

OK, I updated the branch to fix the typo in my run of sed. I also fixed the other issues flake8 was complaining about.

@@ -185,7 +189,6 @@
'albums': {'type': 'array', 'items': sj_album, 'required': False},
'topTracks': {'type': 'array', 'items': sj_track, 'required': False},
'total_albums': {'type': 'integer', 'required': False},
'artistBio': {'type': 'string', 'required': False},
Copy link
Owner

Choose a reason for hiding this comment

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

does this field not exist anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was in the dictionary twice (my editor just flagged it). Look on line 183/187.

Copy link
Owner

Choose a reason for hiding this comment

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

good catch. I've been too lazy too hook up pylint 😁

@simon-weber
Copy link
Owner

Nice work! I just have a few small comments; everything else looks good to go.

@@ -42,7 +47,6 @@
'validictory >= 0.8.0, != 0.9.2', # error messages
'decorator >= 3.3.1', # > 3.0 likely work, but not on pypi
'mutagen >= 1.18', # EasyID3 module renaming
'protobuf >= 2.4.1', # 2.3.0 uses ez_setup?
'requests >= 1.1.0, != 1.2.0, != 2.2.1, < 2.8.0', # session.close, memory view TypeError
'python-dateutil >= 1.3, != 2.0', # 2.0 is python3-only
'proboscis >= 1.2.5.1', # runs_after
Copy link
Owner

Choose a reason for hiding this comment

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

I cut gpsoauth 0.1.0 with the compatibility changes (github doesn't let me comment on that line).

- Use set literals
- Remove unnecessary list conversions
- Convert old_div uses to floor division operator
- Fix example.py
- Install the right version of protobuf in setup.py
- Describe how tox is supposed to work
- Commit tox configuration
@tjstum
Copy link
Contributor Author

tjstum commented Jan 14, 2016

I rewrote the branch to remove the modifications to the binaries. That was unintentional.

72cb306 is the commit with changes discussed here.

I appear to have greatly angered travis, though. I think we might want to turn off E402 (module level import not at top of file). I think the problem is that after we do standard_library.install_aliases(), which is required to make other imports do the right thing, any other import counts at "not at the top of the file," which, while technically correct, is kinda missing the point (IMO). I can change setup.cfg to ignore E402 if it sounds OK to you.
If you do ignore that error, you're left with this:

gmusicapi/session.py:36:13: E731 do not assign a lambda expression, use a def
gmusicapi/clients/musicmanager.py:302:9: E731 do not assign a lambda expression, use a def
gmusicapi/protocol/shared.py:55:9: E731 do not assign a lambda expression, use a def
gmusicapi/protocol/shared.py:56:9: E731 do not assign a lambda expression, use a def
gmusicapi/protocol/shared.py:57:9: E731 do not assign a lambda expression, use a def
gmusicapi/protocol/shared.py:58:9: E731 do not assign a lambda expression, use a def

I think all of those are already marked with # noqa, and I didn't touch those things, so I'm not sure how I awoke the beast. Do either of you have more experience with flake8 to point out what happened here?

@tjstum
Copy link
Contributor Author

tjstum commented Jan 14, 2016

Oh, also. Do you want me to put the .tox directory in .gitignore? It sort of feels like something that should go in a person's core.excludesfile, but I'm happy to do whichever you think is best.

@simon-weber
Copy link
Owner

Do you want me to put the .tox directory in .gitignore?

I guess we may as well, just in case folks are missing it in their global one.

@simon-weber
Copy link
Owner

I can change setup.cfg to ignore E402 if it sounds OK to you.

👍 sounds good.

I think all of those are already marked with # noqa, and I didn't touch those things, so I'm not sure how I awoke the beast.

I think something bizarre happened with the cron I have set up to rerun the develop build periodically. It looks like it triggered at the right time for it to be that, and travis didn't run on the expected sha.

Let's see what happens when it builds your next push.

@simon-weber
Copy link
Owner

Is there anything else you're looking to address? This looks good to me (the linting errors should go away once we merge).

@thebigmunch
Copy link
Contributor

A lot of the list calls wrapping dict methods can be removed to neaten up the code. The futurize script does this indiscriminately for safety, but most instances in gmusicapi are fine without them.

@tjstum
Copy link
Contributor Author

tjstum commented Jan 16, 2016

I'll take a look at the small remaining things later tonight. I'm out of
town this weekend.

Do you need me to squash the branch into fewer commits, or is it fine with
you as is?

On Sat, Jan 16, 2016, 11:56 Simon Weber notifications@github.com wrote:

Is there anything else you're looking to address? This looks good to me
(the linting errors should go away once we merge).


Reply to this email directly or view it on GitHub
#396 (comment)
.

@simon-weber
Copy link
Owner

Sounds good. Squashing would be great right before we merge (before that point it can make review difficult).

@tjstum
Copy link
Contributor Author

tjstum commented Jan 17, 2016

OK, let's see how travis feels after this. (Edit) I don't understand why travis is so upset about this. I can ignore E731? I have no idea what's happening here...

Sounds good. Squashing would be great right before we merge (before that point it can make review difficult).

I was just going to do one commit. Sound fine, @simon-weber?

A lot of the list calls wrapping dict methods can be removed to neaten up the code. The futurize script does this indiscriminately for safety, but most instances in gmusicapi are fine without them.

I cleaned up some of the more gratuitous ones after running futurize. @thebigmunch, if you point me to specific places that you'd like me to remove them from, I will.

@simon-weber
Copy link
Owner

Huh, I can't explain what's going on with travis. It runs on master + your branch, but I don't see anything odd introduced by the merge. Lets not worry about that for now -- if it's still a problem post-merge, hopefully I'll be able to recreate it locally.

Squashing to one commit sounds good 👍

dynamic_requires = []
# Python 2.7 is supported. Python 3 support is experimental
if sys.version_info[0] > 2:
sys.stderr.write("gmusicapi Python 3 support is experimental.\n")
Copy link

Choose a reason for hiding this comment

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

Instead of doing this, can we raise a warning of some sort instead? That way applications can silence the warning (or display it in a way that's more suitable).

@simon-weber Not sure what your thoughts are on warnings?

Copy link
Owner

Choose a reason for hiding this comment

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

Ah, yeah, I like that, and it's backwards compatible with what's done here.

How about warnings.warn("gmusicapi ...", RuntimeWarning)?

@thebigmunch
Copy link
Contributor

@tjstum: From a cursory scan, these are the leftovers I spotted that could be changed.

@tjstum
Copy link
Contributor Author

tjstum commented Jan 18, 2016

@thebigmunch, I took your changes in ffb7f0e. I didn't take some of them, though, since they looked unsafe to me (the ones that modify the dictionary while iterating over it).

@simon-weber, I made some changes to the testing code to reduce the number of warnings that happen during testing. Please let me know if that sounds OK.

If everyone is happy with the branch as of ffb7f0e, I'll squash it down (I can put it in a separate pull request to keep things clear, if that is preferred)

@simon-weber
Copy link
Owner

lgtm 👍

@tjstum tjstum mentioned this pull request Jan 18, 2016
@tjstum
Copy link
Contributor Author

tjstum commented Jan 18, 2016

Squashed and re-opened in #398

@tjstum
Copy link
Contributor Author

tjstum commented Jan 18, 2016

Oh, @simon-weber, I'm not sure I made this entirely clear. I wasn't able to run the All-Access tests (but I could run my application, which downloads AA songs). I mentioned that over email a few months ago, but let me know if there are all of a sudden test failures that I can look at.

Sorry for forgetting to mention this sooner!

@tjstum tjstum closed this Jan 18, 2016
@simon-weber
Copy link
Owner

No worries -- I ran the tests back when you first let me know and they ran fine. Looks like they just passed on travis too 👍

I'll see if I can recreate the flake8 error.

@simon-weber
Copy link
Owner

Looks like it's a bug in flake8; b43a481 fixes it.

@simon-weber
Copy link
Owner

Apparently this is working as intended (!?). @thebigmunch linked me to https://gitlab.com/pycqa/flake8/issues/21.

@tjstum
Copy link
Contributor Author

tjstum commented Jan 18, 2016

Huh. flake8 is so opinionated, I guess

@tjstum tjstum mentioned this pull request Jan 18, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants