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

Python 3 support [WIP] #184

Draft
wants to merge 31 commits into
base: master
Choose a base branch
from
Draft

Python 3 support [WIP] #184

wants to merge 31 commits into from

Conversation

mesozoic
Copy link

I've taken a pass at porting the existing code to Python 3, since it seems like the latest version of macOS has broken a lot of workflows that rely on this (excellent) library. At this point it would be helpful to get feedback on the direction (or help spotting things I've missed).

I started by going test-by-test looking for failures and resolving them incrementally. Kudos on the excellent testing suite with 100% coverage, because it made regressions easy to spot. All the tox tests pass on Python 3.7, 3.8, and 3.9.

There are probably still some places where we do encode/decode hopscotch unnecessarily, but I think it all at least works. I've tested this locally on a workflow that has "vendored" the workflow/ module into its own code, but haven't tested anything that installs this package as a dependency.

I did have to drop the dependency on pytest-httpbin, because I couldn't figure out how to get that to run on Python 3. (traceback) That means the test suite hits the live instance of httpbin.org, which is not great.

I made a first pass at updating the documentation too, but a lot of the examples still need to be reworked.

TODO

  • Reintroduce a local version of httpbin, or something equivalent
  • Do a more thorough pass through documentation, including sample code
  • Confirm that GitHub CI still works (and clean up old CI configs, i.e. Travis)

@@ -1 +1 @@
1.40.0

Choose a reason for hiding this comment

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

Faced an issue due to the added newline to the end of this file.

In workflow/web.py:28, __version__ gets set to "2.0.0\n", which leads to a newline appearing in USER_AGENT:

__version__ = open(os.path.join(os.path.dirname(__file__), 'version')).read()
USER_AGENT = ('Alfred-Workflow/' + __version__ +
' (+http://www.deanishe.net/alfred-workflow)')

USER_AGENT is directly used for the User-Agent header in all requests. On my machine, the requests library doesn't unfold the newline, resulting in urllib.error.HTTPError: HTTP Error 400: Header Folding for every request.

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.

2 participants