Skip to content

Commit a7b48fb

Browse files
authored
Merge pull request #182 remove six
2 parents d1d0d23 + c8fc34b commit a7b48fb

File tree

19 files changed

+32
-83
lines changed

19 files changed

+32
-83
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* Remove six package from code and dependencies (remove support python2)
12
* Use anonymous credentials by default instead of iam metadata (use ydb.driver.credentials_from_env_variables for creds by env var)
23
* Close grpc streams while closing readers/writers
34
* Add control plane operations for topic api: create, drop

examples/reservations-bot-demo/cloud_function/requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ pycparser==2.20
1111
pydantic==1.6.2
1212
PyJWT==2.4.0
1313
requests==2.24.0
14-
six==1.15.0
1514
urllib3==1.26.5
1615
yandexcloud==0.48.0
1716
ydb==0.0.41

kikimr/public/sdk/python/client/__init__.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# -*- coding: utf-8 -*-
22
from ydb import * # noqa
33
import sys
4-
import six
54
import warnings
65

76
warnings.warn("module kikimr.public.sdk.python.client is deprecated. please use ydb instead")
87

98

10-
for name, module in six.iteritems(sys.modules.copy()):
9+
for name, module in sys.modules.copy().items():
1110
if not name.startswith("ydb"):
1211
continue
1312

test-requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ pytest-docker-compose==3.2.1
3232
python-dotenv==0.18.0
3333
PyYAML==5.4.1
3434
requests==2.26.0
35-
six==1.16.0
3635
texttable==1.6.4
3736
toml==0.10.2
3837
typing-extensions==3.10.0.0

ydb/_sp_impl.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
import collections
33
from concurrent import futures
4-
from six.moves import queue
4+
import queue
55
import time
66
import threading
77
from . import settings, issues, _utilities, tracing

ydb/_utilities.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# -*- coding: utf-8 -*-
2-
import six
32
import codecs
43
from concurrent import futures
54
import functools
65
import hashlib
76
import collections
7+
import urllib.parse
88
from . import ydb_version
99

1010
try:
@@ -55,8 +55,8 @@ def parse_connection_string(connection_string):
5555
# default is grpcs
5656
cs = _grpcs_protocol + cs
5757

58-
p = six.moves.urllib.parse.urlparse(connection_string)
59-
b = six.moves.urllib.parse.parse_qs(p.query)
58+
p = urllib.parse.urlparse(connection_string)
59+
b = urllib.parse.parse_qs(p.query)
6060
database = b.get("database", [])
6161
assert len(database) > 0
6262

@@ -77,11 +77,9 @@ def decorator(*args, **kwargs):
7777

7878
def get_query_hash(yql_text):
7979
try:
80-
return hashlib.sha256(
81-
six.text_type(yql_text, "utf-8").encode("utf-8")
82-
).hexdigest()
80+
return hashlib.sha256(str(yql_text, "utf-8").encode("utf-8")).hexdigest()
8381
except TypeError:
84-
return hashlib.sha256(six.text_type(yql_text).encode("utf-8")).hexdigest()
82+
return hashlib.sha256(str(yql_text).encode("utf-8")).hexdigest()
8583

8684

8785
class LRUCache(object):

ydb/aio/credentials.py

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import abc
44
import asyncio
55
import logging
6-
import six
76
from ydb import issues, credentials
87

98
logger = logging.getLogger(__name__)
@@ -55,7 +54,6 @@ def submit(self, callback):
5554
asyncio.ensure_future(self._wrapped_execution(callback))
5655

5756

58-
@six.add_metaclass(abc.ABCMeta)
5957
class AbstractExpiringTokenCredentials(credentials.AbstractExpiringTokenCredentials):
6058
def __init__(self):
6159
super(AbstractExpiringTokenCredentials, self).__init__()

ydb/aio/iam.py

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import abc
55
import logging
6-
import six
76
from ydb.iam import auth
87
from .credentials import AbstractExpiringTokenCredentials
98

@@ -24,7 +23,6 @@
2423
aiohttp = None
2524

2625

27-
@six.add_metaclass(abc.ABCMeta)
2826
class TokenServiceCredentials(AbstractExpiringTokenCredentials):
2927
def __init__(self, iam_endpoint=None, iam_channel_credentials=None):
3028
super(TokenServiceCredentials, self).__init__()

ydb/convert.py

+6-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# -*- coding: utf-8 -*-
22
import decimal
33
from google.protobuf import struct_pb2
4-
import six
54

65
from . import issues, types, _apis
76

@@ -81,9 +80,7 @@ def _pb_to_list(type_pb, value_pb, table_client_settings):
8180
def _pb_to_tuple(type_pb, value_pb, table_client_settings):
8281
return tuple(
8382
_to_native_value(item_type, item_value, table_client_settings)
84-
for item_type, item_value in six.moves.zip(
85-
type_pb.tuple_type.elements, value_pb.items
86-
)
83+
for item_type, item_value in zip(type_pb.tuple_type.elements, value_pb.items)
8784
)
8885

8986

@@ -106,7 +103,7 @@ class _Struct(_DotDict):
106103

107104
def _pb_to_struct(type_pb, value_pb, table_client_settings):
108105
result = _Struct()
109-
for member, item in six.moves.zip(type_pb.struct_type.members, value_pb.items):
106+
for member, item in zip(type_pb.struct_type.members, value_pb.items):
110107
result[member.name] = _to_native_value(member.type, item, table_client_settings)
111108
return result
112109

@@ -201,9 +198,7 @@ def _list_to_pb(type_pb, value):
201198

202199
def _tuple_to_pb(type_pb, value):
203200
value_pb = _apis.ydb_value.Value()
204-
for element_type, element_value in six.moves.zip(
205-
type_pb.tuple_type.elements, value
206-
):
201+
for element_type, element_value in zip(type_pb.tuple_type.elements, value):
207202
value_item_proto = value_pb.items.add()
208203
value_item_proto.MergeFrom(_from_native_value(element_type, element_value))
209204
return value_pb
@@ -289,7 +284,7 @@ def parameters_to_pb(parameters_types, parameters_values):
289284
return {}
290285

291286
param_values_pb = {}
292-
for name, type_pb in six.iteritems(parameters_types):
287+
for name, type_pb in parameters_types.items():
293288
result = _apis.ydb_value.TypedValue()
294289
ttype = type_pb
295290
if isinstance(type_pb, types.AbstractTypeBuilder):
@@ -330,7 +325,7 @@ def from_message(cls, message, table_client_settings=None):
330325

331326
for row_proto in message.rows:
332327
row = _Row(message.columns)
333-
for column, value, column_info in six.moves.zip(
328+
for column, value, column_info in zip(
334329
message.columns, row_proto.items, column_parsers
335330
):
336331
v_type = value.WhichOneof("value")
@@ -398,9 +393,7 @@ def __init__(self, columns, proto_row, table_client_settings, parsers):
398393
super(_LazyRow, self).__init__()
399394
self._columns = columns
400395
self._table_client_settings = table_client_settings
401-
for i, (column, row_item) in enumerate(
402-
six.moves.zip(self._columns, proto_row.items)
403-
):
396+
for i, (column, row_item) in enumerate(zip(self._columns, proto_row.items)):
404397
super(_LazyRow, self).__setitem__(
405398
column.name,
406399
_LazyRowItem(row_item, column.type, table_client_settings, parsers[i]),

ydb/credentials.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import abc
33
import typing
44

5-
import six
65
from . import tracing, issues, connection
76
from . import settings as settings_impl
87
import threading
@@ -23,15 +22,13 @@
2322
logger = logging.getLogger(__name__)
2423

2524

26-
@six.add_metaclass(abc.ABCMeta)
27-
class AbstractCredentials(object):
25+
class AbstractCredentials(abc.ABC):
2826
"""
2927
An abstract class that provides auth metadata
3028
"""
3129

3230

33-
@six.add_metaclass(abc.ABCMeta)
34-
class Credentials(object):
31+
class Credentials(abc.ABC):
3532
def __init__(self, tracer=None):
3633
self.tracer = tracer if tracer is not None else tracing.Tracer(None)
3734

@@ -88,7 +85,6 @@ def cleanup(self):
8885
self._can_schedule = True
8986

9087

91-
@six.add_metaclass(abc.ABCMeta)
9288
class AbstractExpiringTokenCredentials(Credentials):
9389
def __init__(self, tracer=None):
9490
super(AbstractExpiringTokenCredentials, self).__init__(tracer)

ydb/dbapi/cursor.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import itertools
66
import logging
77

8-
import six
9-
108
import ydb
119
from .errors import DatabaseError
1210

@@ -42,7 +40,7 @@ def render_datetime(value):
4240
def render(value):
4341
if value is None:
4442
return "NULL"
45-
if isinstance(value, six.string_types):
43+
if isinstance(value, str):
4644
return render_str(value)
4745
if isinstance(value, datetime.datetime):
4846
return render_datetime(value)

ydb/default_pem.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import six
2-
3-
41
data = """
52
# Issuer: CN=GlobalSign Root CA O=GlobalSign nv-sa OU=Root CA
63
# Subject: CN=GlobalSign Root CA O=GlobalSign nv-sa OU=Root CA
@@ -4686,6 +4683,4 @@
46864683
def load_default_pem():
46874684
global data
46884685

4689-
if six.PY3:
4690-
return data.encode("utf-8")
4691-
return data
4686+
return data.encode("utf-8")

ydb/driver.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
# -*- coding: utf-8 -*-
22
from . import credentials as credentials_impl, table, scheme, pool
33
from . import tracing
4-
import six
54
import os
65
import grpc
76
from . import _utilities
87

9-
if six.PY2:
10-
Any = None
11-
else:
12-
from typing import Any # noqa
8+
from typing import Any # noqa
139

1410

1511
class RPCCompression:

ydb/iam/auth.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import grpc
44
import time
55
import abc
6-
import six
76
from datetime import datetime
87
import json
98
import os
@@ -45,7 +44,6 @@ def get_jwt(account_id, access_key_id, private_key, jwt_expiration_timeout):
4544
)
4645

4746

48-
@six.add_metaclass(abc.ABCMeta)
4947
class TokenServiceCredentials(credentials.AbstractExpiringTokenCredentials):
5048
def __init__(self, iam_endpoint=None, iam_channel_credentials=None, tracer=None):
5149
super(TokenServiceCredentials, self).__init__(tracer)
@@ -84,8 +82,7 @@ def _make_token_request(self):
8482
return {"access_token": response.iam_token, "expires_in": expires_in}
8583

8684

87-
@six.add_metaclass(abc.ABCMeta)
88-
class BaseJWTCredentials(object):
85+
class BaseJWTCredentials(abc.ABC):
8986
def __init__(self, account_id, access_key_id, private_key):
9087
self._account_id = account_id
9188
self._jwt_expiration_timeout = 60.0 * 60

ydb/issues.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
from google.protobuf import text_format
33
import enum
4-
from six.moves import queue
4+
import queue
55

66
from . import _apis
77

ydb/pool.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# -*- coding: utf-8 -*-
2+
import abc
23
import threading
34
import logging
45
from concurrent import futures
56
import collections
67
import random
78

8-
import six
9-
109
from . import connection as connection_impl, issues, resolver, _utilities, tracing
11-
from abc import abstractmethod, ABCMeta
10+
from abc import abstractmethod
1211

1312
from .connection import Connection
1413

@@ -296,8 +295,7 @@ def run(self):
296295
self.logger.info("Successfully terminated discovery process")
297296

298297

299-
@six.add_metaclass(ABCMeta)
300-
class IConnectionPool:
298+
class IConnectionPool(abc.ABC):
301299
@abstractmethod
302300
def __init__(self, driver_config):
303301
"""

ydb/scheme.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# -*- coding: utf-8 -*-
22
import abc
33
import enum
4-
import six
54
from abc import abstractmethod
65
from . import issues, operation, settings as settings_impl, _apis
76

@@ -347,8 +346,7 @@ def _wrap_describe_path_response(rpc_state, response):
347346
return _wrap_scheme_entry(message.self)
348347

349348

350-
@six.add_metaclass(abc.ABCMeta)
351-
class ISchemeClient:
349+
class ISchemeClient(abc.ABC):
352350
@abstractmethod
353351
def __init__(self, driver):
354352
pass

0 commit comments

Comments
 (0)