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

Use six instead of twisted.python.compat #290

Merged
merged 12 commits into from
Sep 9, 2020

Conversation

altendky
Copy link
Member

@altendky altendky commented Sep 7, 2020

@altendky altendky marked this pull request as draft September 7, 2020 19:21
@altendky
Copy link
Member Author

altendky commented Sep 7, 2020

I'm guessing an empty newsfragment isn't needed here. If it is, let me know.

@altendky altendky marked this pull request as ready for review September 7, 2020 19:30
src/treq/client.py Outdated Show resolved Hide resolved
src/treq/multipart.py Outdated Show resolved Hide resolved
src/treq/client.py Outdated Show resolved Hide resolved
src/treq/client.py Outdated Show resolved Hide resolved
@altendky altendky marked this pull request as draft September 7, 2020 19:58
src/treq/client.py Outdated Show resolved Hide resolved
src/treq/client.py Outdated Show resolved Hide resolved
@altendky altendky changed the title Use six.PY3 instead of twisted.python.compat._PY3 Use six instead of twisted.python.compat Sep 7, 2020
src/treq/client.py Outdated Show resolved Hide resolved
@@ -377,12 +364,10 @@ def _guess_content_type(filename):
registerAdapter(_from_bytes, bytes, IBodyProducer)
registerAdapter(_from_file, BytesIO, IBodyProducer)

if not _PY3:
from StringIO import StringIO
if PY2:
registerAdapter(_from_file, StringIO, IBodyProducer)
Copy link
Member

Choose a reason for hiding this comment

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

io.StringIO is the wrong StringIO

Suggested change
registerAdapter(_from_file, StringIO, IBodyProducer)
registerAdapter(_from_file, six.StringIO, IBodyProducer)

Copy link
Member

Choose a reason for hiding this comment

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

it's best to

import io
import six

and then use io.StringIO or six.StringIO so it's obvious

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it is coming from six. (aren't these from imports great?)

Copy link
Member

Choose a reason for hiding this comment

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

ah right, that's super confusing

Copy link
Member

Choose a reason for hiding this comment

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

@altendky the first hit for six uses an idiomatic import:

Copy link
Member

Choose a reason for hiding this comment

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

I'd recommend following modernize here and using idiomatic-style imports for both io and six https://modernize.readthedocs.io/en/latest/fixers.html#unicode_type

Copy link
Member Author

Choose a reason for hiding this comment

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

Over following the existing local practice? (and that import is off in some other file that i didn't get to touching)

@altendky altendky marked this pull request as ready for review September 8, 2020 15:08
@twm
Copy link
Contributor

twm commented Sep 9, 2020

A newsfile along the lines of "Compatibility with Twisted 20.9.0" would be nice, except we don't know what version to put there. I will add that retroactively I guess.

@twm
Copy link
Contributor

twm commented Sep 9, 2020

Thank you both for this! I will release once #284 is in.

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.

4 participants