Skip to content

Use six instead of twisted.python.compat - #290

Merged
twm merged 12 commits into
twisted:masterfrom
altendky:288-altendky-six.PY3
Sep 9, 2020
Merged

twm merged 12 commits into
twisted:masterfrom
altendky:288-altendky-six.PY3

Conversation

@altendky

@altendky altendky commented Sep 7, 2020

Copy link
Copy Markdown
Member

@altendky
altendky marked this pull request as draft September 7, 2020 19:21
@altendky

altendky commented Sep 7, 2020

Copy link
Copy Markdown
Member Author

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
Comment thread src/treq/client.py Resolved
Comment thread src/treq/multipart.py Resolved
Comment thread src/treq/client.py Resolved
Comment thread src/treq/client.py Resolved
@altendky
altendky marked this pull request as draft September 7, 2020 19:58
Comment thread src/treq/client.py Resolved
Comment thread src/treq/client.py 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
Comment thread src/treq/client.py Resolved
Comment thread src/treq/client.py Resolved
Comment thread src/treq/client.py Outdated
if not _PY3:
from StringIO import StringIO
if PY2:
registerAdapter(_from_file, StringIO, IBodyProducer)

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

twm commented Sep 9, 2020

Copy link
Copy Markdown
Member

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

twm commented Sep 9, 2020

Copy link
Copy Markdown
Member

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