-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Alternate approach to enhancing Python 3 support #2918
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
Conversation
…d commit we used to be on.
BEFORE: We were using a pinned commit where that functionality was added.
Depend on futurize.
The futurize script made sure we were using the Unicode version of StringIO, so we needed to actually coerce incoming bytes to Unicode. This is a slight behavior change on Python 2, but I believe it to be an improvement because it makes another codepath Unicode-clean.
…s part of the test environment.
.travis.yml
Outdated
@@ -1,9 +1,11 @@ | |||
language: python | |||
python: | |||
- 2.7 | |||
- 3.6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe TOX handles the Python env, so having this both places means we run all of the tests 2x. I think we can remove this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or, we can remove the 2.7, and run them all in 3.6 -- I see travis fails with "no 3.6 found" when running under 2.7.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I added 3.6 to get around the weird error in 2.7, but that exploded the build matrix, so I tried to add the tox-travis plugin to make the integration smarter, but never got it properly configured. If 2.7 is working under 3.6, I think the right play is to pull out the tox-travis plugin and just tell travis to use 3.6
Any thoughts on the lint error? I'm guessing it's a version mismatch between prospector and one of the other linting tools. We've run into that before. Otherwise, this is amazing! I'll try and take a look and get it merged next week. ❤️ |
RE: the lint error -> It looks like pydocstyle added an option to |
Dropping prospector back a minor release fixes this problem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added mostly code cleanup feedback. I think to get this merged before it rots, lets mark the tests failing in py3 as expected failure for py3 environments and open a ticket to address resolving those issues. We'll stick with defaulting to py2 for now for tests/etc. Does this sound reasonable?
@@ -1,9 +1,10 @@ | |||
language: python | |||
python: | |||
- 2.7 | |||
- 3.6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps default to 2.7 for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason, Travis fails and says it can't find the Python 3.6 interpreter when we do it on 2.7. The 2.7 tests seem to work fine when we tell Travis to use 3.6. Apparently just some quirk with the Travis and tox
interactions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, strange. Perhaps this is another motivator for switching to our newer standard tox.ini/travis.yml config, like: https://github.com/rtfd/sphinx_rtd_theme
If this is working as expected, probably no strong reason to switch just yet though
@@ -8,6 +9,7 @@ | |||
|
|||
from readthedocs.constants import pattern_opts | |||
from readthedocs.core.views import serve | |||
from functools import reduce |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import order is wrong here. should be pep8 standard of: builtins, third party, then local imports
readthedocs/core/urls/subdomain.py
Outdated
from operator import add | ||
|
||
from django.conf.urls import url, patterns | ||
from django.conf import settings | ||
from django.conf.urls.static import static | ||
|
||
from readthedocs.constants import pattern_opts | ||
from functools import reduce |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import order off here too
readthedocs/doc_builder/config.py
Outdated
from readthedocs_build.config import (ConfigError, BuildConfig, InvalidConfig, | ||
load as load_config) | ||
|
||
|
||
from .constants import BUILD_IMAGES, DOCKER_IMAGE | ||
from six.moves import filter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import order off here as well
readthedocs/donate/models.py
Outdated
@@ -16,8 +22,10 @@ | |||
) | |||
from readthedocs.projects.models import Project | |||
from readthedocs.projects.constants import PROGRAMMING_LANGUAGES | |||
import six |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import order here as well
from io import StringIO | ||
else: | ||
from StringIO import StringIO | ||
from io import StringIO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import order here
@@ -113,10 +114,13 @@ def parse_tags(self, data): | |||
hash as identifier. | |||
""" | |||
# parse the lines into a list of tuples (commit-hash, tag ref name) | |||
# StringIO below is expecting Unicode data, so ensure that it gets it. | |||
if not isinstance(data, str): | |||
data = str(data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
str -> six.text_type
again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See notes about svn.py
.
@@ -147,9 +151,12 @@ def parse_branches(self, data): | |||
origin/release/2.1.0 | |||
""" | |||
clean_branches = [] | |||
# StringIO below is expecting Unicode data, so ensure that it gets it. | |||
if not isinstance(data, str): | |||
data = str(data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
str
-> six.text_type
here too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See notes about svn.py
.
|
||
# StringIO below is expecting Unicode data, so ensure that it gets it. | ||
if not isinstance(data, str): | ||
data = str(data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
str
-> six.text_type
here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+from future import standard_library
+standard_library.install_aliases()
basically makes str
on Python 2 act like unicode
and adds bytes
as the equivalent to the original str
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah gotcha, missed that. These all make sense then.
packaging==16.8 | ||
|
||
# Commenting stuff | ||
git+https://github.com/zestedesavoir/django-cors-middleware.git@def9dc2f5e81eed53831bcda79ad1c127ecb3fe2 | ||
django-cors-middleware==1.3.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why this one was pinned to a commit. @ericholscher any background here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I recall, that commit was merging in a change from Eric that added some Django signals support, and now it's included in a public release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds right: zestedesavoir/django-cors-middleware@466d378
@ericholscher Could you first drop in on #2918 (comment), it's not clear why code was removed there, and that is also blocking review. |
So close :) |
Since this is only failing at linting, I'll do some local testing to confirm nothing is horribly broken, and it looks close! 🎆 |
@ericholscher sounds like this is close, we are discussing on IRC. probably no need to jump in. The plan for now is to get python3 tests working, which involve upgrading some of the lint/testing deps. I'm addressing that in #2863 and the merge will be cherrypicked here, so conflicts will be low. I'm less worried about rot as that PR and the restapi PR will be the only two conflicting commits and we can probably merge this all in early next week. |
I think there will be manual testing required before we deploy these changes to prod, which is what I'm referring to. I'm happy to do it after we merge it. |
Ugh @ restapi conflicts :( @agjohnson |
Yup, this was discussed already and we anticipated having to rebase some work for this and fixing testing. |
Okay, wrapped up #2863. I'm going to try to rebase this on a separate branch and see what happens. |
Okay, we're all set here. I merged everything together in another PR, so I'll just close this PR and merge that branch into master. I'm super excited to get going with python 3. Thanks a ton for putting in the work on this one, @gthank! |
I'm excited, too! Thanks for letting me chip in, everybody. |
The same basic work, but ordered differently and tested more incrementally.