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

Remove six #493

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions dropbox/dropbox_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import time

import requests
import six

from datetime import datetime, timedelta
from dropbox.auth import (
Expand Down Expand Up @@ -75,7 +74,7 @@ def __init__(self, obj_result, http_resp=None):
:param requests.models.Response http_resp: A raw HTTP response. It will
be used to stream the binary-body payload of the response.
"""
assert isinstance(obj_result, six.string_types), \
assert isinstance(obj_result, str), \
'obj_result: expected string, got %r' % type(obj_result)
if http_resp is not None:
assert isinstance(http_resp, requests.models.Response), \
Expand Down Expand Up @@ -530,7 +529,7 @@ def request_json_string(self,
if host not in self._host_map:
raise ValueError('Unknown value for host: %r' % host)

if not isinstance(request_binary, (six.binary_type, type(None))):
if not isinstance(request_binary, (bytes, type(None))):
# Disallow streams and file-like objects even though the underlying
# requests library supports them. This is to prevent incorrect
# behavior when a non-rewindable stream is read from, but the
Expand Down
25 changes: 7 additions & 18 deletions dropbox/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import base64
import os
import six
import urllib
import re
from datetime import datetime, timedelta
Expand All @@ -26,13 +25,6 @@
DEFAULT_TIMEOUT,
)

if six.PY3:
url_path_quote = urllib.parse.quote # pylint: disable=no-member,useless-suppression
url_encode = urllib.parse.urlencode # pylint: disable=no-member,useless-suppression
else:
url_path_quote = urllib.quote # pylint: disable=no-member,useless-suppression
url_encode = urllib.urlencode # pylint: disable=no-member,useless-suppression

TOKEN_ACCESS_TYPES = ['offline', 'online', 'legacy']

Choose a reason for hiding this comment

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

something is missing

INCLUDE_GRANTED_SCOPES_TYPES = ['user', 'team']
PKCE_VERIFIER_LENGTH = 128
Expand Down Expand Up @@ -233,10 +225,7 @@ def build_path(self, target, params=None):
:return: The path and parameters components of an API URL.
:rtype: str
"""
if six.PY2 and isinstance(target, six.text_type):
target = target.encode('utf8')

target_path = url_path_quote(target)
target_path = urllib.parse.quote(target)

params = params or {}
params = params.copy()
Expand Down Expand Up @@ -606,20 +595,20 @@ def _params_to_urlencoded(params):
Returns a application/x-www-form-urlencoded :class:`str` representing the key/value pairs in
:attr:`params`.

Keys are values are ``str()``'d before calling :meth:`urllib.urlencode`, with the exception of
unicode objects which are utf8-encoded.
Keys and values are coerced via ``str()`` and encoded via UTF-8 before calling
:meth:`urllib.parse.urlencode`.
"""
def encode(o):
if isinstance(o, six.binary_type):
if isinstance(o, bytes):
return o
else:
if isinstance(o, six.text_type):
if isinstance(o, str):
return o.encode('utf-8')
else:
return str(o).encode('utf-8')

utf8_params = {encode(k): encode(v) for k, v in six.iteritems(params)}
return url_encode(utf8_params)
utf8_params = {encode(k): encode(v) for k, v in params.items()}
return urllib.parse.urlencode(utf8_params)

def _generate_pkce_code_verifier():
code_verifier = base64.urlsafe_b64encode(os.urandom(PKCE_VERIFIER_LENGTH)).decode('utf-8')
Expand Down
3 changes: 1 addition & 2 deletions example/updown.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import contextlib
import datetime
import os
import six
import sys
import time
import unicodedata
Expand Down Expand Up @@ -74,7 +73,7 @@ def main():
# First do all the files.
for name in files:
fullname = os.path.join(dn, name)
if not isinstance(name, six.text_type):
if not isinstance(name, str):
name = name.decode('utf-8')
nname = unicodedata.normalize('NFC', name)
if name.startswith('.'):
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Dependencies required for installation (keep in sync with setup.py)
requests<2.30
urllib3<2
six >= 1.12.0
stone>=2,<3.3.3
# Other dependencies for development
ply
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
install_reqs = [
'requests<2.30',
'urllib3<2',
'six >= 1.12.0',
'stone>=2,<3.3.3',
]

Expand Down
Loading