Skip to content

Commit 769107d

Browse files
committed
remove py2 compatibility
1 parent b7c5d65 commit 769107d

File tree

12 files changed

+28
-42
lines changed

12 files changed

+28
-42
lines changed

setup.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@
5454
'requests>=2.4.2',
5555
'cryptography==3.3.1',
5656
'PyJWT==2.0.1',
57-
'six',
58-
'enum34;python_version<"3.4"',
5957
],
6058
extras_require={
6159
'test': test_deps,

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import logging
2525

2626
import pytest
27-
from six import StringIO
27+
from io import StringIO
2828

2929
mock_connection_params = {
3030
"org_id": "N/A",

tests/test_connections.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import mock
2525
import pytest
2626
import requests
27-
import six
2827

2928
from conftest import mock_connection_params, MockResponse
3029

@@ -310,7 +309,7 @@ def test_large_group_assignment_split():
310309
:return:
311310
"""
312311
group_prefix = "G"
313-
add_groups = [group_prefix+six.text_type(n+1) for n in range(0, 15)]
312+
add_groups = [group_prefix+str(n+1) for n in range(0, 15)]
314313
user = UserAction(id_type=IdentityTypes.enterpriseID, email="[email protected]")
315314
user.add_to_groups(groups=add_groups, group_type=GroupTypes.usergroup)
316315
assert user.maybe_split_groups(10) is True
@@ -325,7 +324,7 @@ def test_large_group_assignment_split_recursive():
325324
:return:
326325
"""
327326
group_prefix = "G"
328-
add_groups = [group_prefix+six.text_type(n+1) for n in range(0, 100)]
327+
add_groups = [group_prefix+str(n+1) for n in range(0, 100)]
329328
user = UserAction(id_type=IdentityTypes.enterpriseID, email="[email protected]")
330329
user.add_to_groups(groups=add_groups, group_type=GroupTypes.usergroup)
331330
assert user.maybe_split_groups(10) is True
@@ -339,8 +338,8 @@ def test_large_group_mix_split():
339338
:return:
340339
"""
341340
group_prefix = "G"
342-
add_groups = [group_prefix+six.text_type(n+1) for n in range(0, 15)]
343-
remove_groups = [group_prefix+six.text_type(n+1) for n in range(15, 30)]
341+
add_groups = [group_prefix+str(n+1) for n in range(0, 15)]
342+
remove_groups = [group_prefix+str(n+1) for n in range(15, 30)]
344343
user = UserAction(id_type=IdentityTypes.enterpriseID, email="[email protected]")
345344
user.add_to_groups(groups=add_groups, group_type=GroupTypes.usergroup) \
346345
.remove_from_groups(groups=remove_groups, group_type=GroupTypes.usergroup)
@@ -364,7 +363,7 @@ def test_large_group_action_split():
364363
conn = Connection(**mock_connection_params)
365364

366365
group_prefix = "G"
367-
add_groups = [group_prefix+six.text_type(n+1) for n in range(0, 150)]
366+
add_groups = [group_prefix+str(n+1) for n in range(0, 150)]
368367
user = UserAction(id_type=IdentityTypes.enterpriseID, email="[email protected]")
369368
user.add_to_groups(groups=add_groups, group_type=GroupTypes.usergroup)
370369
assert conn.execute_single(user, immediate=True) == (0, 2, 2)
@@ -382,7 +381,7 @@ def test_group_size_limit():
382381
conn = Connection(**params)
383382

384383
group_prefix = "G"
385-
add_groups = [group_prefix+six.text_type(n+1) for n in range(0, 150)]
384+
add_groups = [group_prefix+str(n+1) for n in range(0, 150)]
386385
user = UserAction(id_type=IdentityTypes.enterpriseID, email="[email protected]")
387386
user.add_to_groups(groups=add_groups, group_type=GroupTypes.usergroup)
388387
assert conn.execute_single(user, immediate=True) == (0, 3, 3)
@@ -409,7 +408,7 @@ def test_split_add_user():
409408

410409
def test_split_role_assignment():
411410
group_prefix = "G"
412-
add_groups = [group_prefix+six.text_type(n+1) for n in range(0, 25)]
411+
add_groups = [group_prefix+str(n+1) for n in range(0, 25)]
413412
user = UserAction(id_type=IdentityTypes.enterpriseID, email="[email protected]")
414413
user.add_role(groups=add_groups, role_type=RoleTypes.admin)
415414
assert user.maybe_split_groups(10) is True
@@ -422,7 +421,7 @@ def test_no_group_split():
422421
:return:
423422
"""
424423
group_prefix = "G"
425-
add_groups = [group_prefix+six.text_type(n+1) for n in range(0, 5)]
424+
add_groups = [group_prefix+str(n+1) for n in range(0, 5)]
426425
user = UserAction(id_type=IdentityTypes.enterpriseID, email="[email protected]")
427426
user.add_to_groups(groups=add_groups, group_type=GroupTypes.usergroup)
428427
assert user.maybe_split_groups(10) is False
@@ -436,8 +435,8 @@ def test_complex_group_split():
436435
:return:
437436
"""
438437
group_prefix = "G"
439-
add_groups = [group_prefix+six.text_type(n+1) for n in range(0, 150)]
440-
add_products = [group_prefix+six.text_type(n+1) for n in range(0, 26)]
438+
add_groups = [group_prefix+str(n+1) for n in range(0, 150)]
439+
add_products = [group_prefix+str(n+1) for n in range(0, 26)]
441440
user = UserAction(id_type=IdentityTypes.enterpriseID, email="[email protected]")
442441
user.commands = [{
443442
"add": {
@@ -457,7 +456,7 @@ def test_split_remove_all():
457456
:return:
458457
"""
459458
group_prefix = "G"
460-
add_groups = [group_prefix+six.text_type(n+1) for n in range(0, 11)]
459+
add_groups = [group_prefix+str(n+1) for n in range(0, 11)]
461460
user = UserAction(id_type=IdentityTypes.enterpriseID, email="[email protected]")
462461
user.remove_from_groups(all_groups=True)
463462
assert user.maybe_split_groups(1) is False
@@ -480,7 +479,7 @@ def test_split_remove_all():
480479

481480

482481
def test_split_group_action():
483-
user_template = six.text_type("user.{}@example.com")
482+
user_template = "user.{}@example.com"
484483
add_users = [user_template.format(n+1) for n in range(0, 25)]
485484
group = UserGroupAction(group_name="Test Group")
486485
group.add_users(users=add_users)

tests/test_functional.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
# SOFTWARE.
2222

2323
import pytest
24-
import six
25-
import mock
2624

2725
from conftest import mock_connection_params, MockResponse
2826
from umapi_client import ArgumentError, RequestError

tests/test_legacy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import mock
2727
import pytest
2828
from conftest import MockResponse
29-
from six import StringIO
29+
from io import StringIO
3030

3131
import umapi_client.legacy as v1
3232

tests/test_live.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
import pytest
2626
import yaml
27-
import six
2827

2928
import umapi_client
3029

@@ -134,7 +133,7 @@ def test_get_user(config):
134133
user_query = umapi_client.UserQuery(conn, params["test_user"]["email"])
135134
user = user_query.result()
136135
logging.info("User: %s", user)
137-
for k, v in six.iteritems(params["test_user"]):
136+
for k, v in params["test_user"].items():
138137
assert user[k].lower() == v.lower()
139138

140139

umapi_client/api.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1919
# SOFTWARE.
2020

21-
import six
22-
2321
from .connection import Connection
2422

2523

@@ -76,7 +74,7 @@ def append(self, **kwargs):
7674
:param kwargs: the key/value pairs to add
7775
:return: the action
7876
"""
79-
for k, v in six.iteritems(kwargs):
77+
for k, v in kwargs.items():
8078
self.commands.append({k: v})
8179
return self
8280

@@ -95,7 +93,7 @@ def insert(self, **kwargs):
9593
:param kwargs: the key/value pair to append first
9694
:return: the action, so you can append Action(...).insert(...).append(...)
9795
"""
98-
for k, v in six.iteritems(kwargs):
96+
for k, v in kwargs.items():
9997
self.commands.insert(0, {k: v})
10098
return self
10199

@@ -139,14 +137,14 @@ def maybe_split_groups(self, max_groups):
139137
valid_step_keys = ['add', 'addRoles', 'remove']
140138
for command in self.commands:
141139
# commands are assumed to contain a single key
142-
step_key, step_args = next(six.iteritems(command))
140+
step_key, step_args = next(iter(command.items()))
143141
if step_key not in valid_step_keys or not isinstance(step_args, dict):
144142
split_commands.append(command)
145143
continue
146144
new_commands = [command]
147145
while True:
148146
new_command = {step_key: {}}
149-
for group_type, groups in six.iteritems(command[step_key]):
147+
for group_type, groups in command[step_key].items():
150148
if len(groups) > max_groups:
151149
command[step_key][group_type], new_command[step_key][group_type] = \
152150
groups[0:max_groups], groups[max_groups:]

umapi_client/auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
import jwt # package name is PyJWT in setup
2525
import requests
26-
import six.moves.urllib.parse as urlparse
26+
import urllib.parse as urlparse
2727

2828

2929
class JWT(object):

umapi_client/connection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
from random import randint
2727
from time import time, sleep, gmtime, strftime
2828
import requests
29-
import six
30-
import six.moves.urllib.parse as urlparse
29+
import io
30+
import urllib.parse as urlparse
3131

3232
from .auth import JWT, Auth, AccessRequest
3333
from .error import BatchError, UnavailableError, ClientError, RequestError, ServerError, ArgumentError
@@ -194,7 +194,7 @@ def _get_auth(self, ims_host, ims_endpoint_jwt,
194194
if not (tech_acct_id and api_key and client_secret and (private_key_data or private_key_file)):
195195
raise ArgumentError("Connector create: not all required auth parameters were supplied; please see docs")
196196
if private_key_data:
197-
jwt = JWT(self.org_id, tech_acct_id, ims_host, api_key, six.StringIO(private_key_data))
197+
jwt = JWT(self.org_id, tech_acct_id, ims_host, api_key, io.StringIO(private_key_data))
198198
else:
199199
with open(private_key_file, 'r') as private_key_stream:
200200
jwt = JWT(self.org_id, tech_acct_id, ims_host, api_key, private_key_stream)

umapi_client/error.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1919
# SOFTWARE.
2020

21-
import six
22-
2321

2422
class UnavailableError(Exception):
2523
def __init__(self, attempts, seconds, result):
@@ -58,8 +56,6 @@ def __init__(self, causes, queued, sent, completed):
5856

5957
class ArgumentError(ValueError):
6058
def __init__(self, message):
61-
if six.PY2 and isinstance(message, unicode):
62-
message = message.encode('utf8')
6359
ValueError.__init__(self, message)
6460

6561

0 commit comments

Comments
 (0)