Skip to content

Commit 36a04a9

Browse files
authored
remove more Python2 compatibility (#560)
1 parent a67d90b commit 36a04a9

File tree

12 files changed

+15
-22
lines changed

12 files changed

+15
-22
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ cur.executemany("INSERT INTO table (a, b) VALUES (%s, %s)", [[100, value]], use_
716716
##### Register new SQL literal adapters
717717
It is possible to adapt new Python types to SQL literals via `Cursor.register_sql_literal_adapter(py_class_or_type, adapter_function)` function. Example:
718718
```python
719-
class Point(object):
719+
class Point:
720720
def __init__(self, x, y):
721721
self.x = x
722722
self.y = y

Diff for: requirements-dev.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
pytest
22
pytest-timeout
33
python-dateutil
4-
six
54
tox
65
#kerberos

Diff for: setup.py

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
python_requires=">=3.7",
6060
install_requires=[
6161
'python-dateutil>=1.5',
62-
'six>=1.10.0'
6362
],
6463
classifiers=[
6564
"Development Status :: 5 - Production/Stable",

Diff for: vertica_python/compat.py

+4-9
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@
6363
* `real_types`
6464
"""
6565

66-
import six as _six
67-
6866

6967
def as_bytes(bytes_or_text, encoding='utf-8'):
7068
"""Converts either bytes or unicode to `bytes`, using utf-8 encoding for text.
@@ -76,7 +74,7 @@ def as_bytes(bytes_or_text, encoding='utf-8'):
7674
Raises:
7775
TypeError: If `bytes_or_text` is not a binary or unicode string.
7876
"""
79-
if isinstance(bytes_or_text, _six.text_type):
77+
if isinstance(bytes_or_text, str):
8078
return bytes_or_text.encode(encoding)
8179
elif isinstance(bytes_or_text, bytearray):
8280
return bytes(bytes_or_text)
@@ -97,7 +95,7 @@ def as_text(bytes_or_text, encoding='utf-8'):
9795
Raises:
9896
TypeError: If `bytes_or_text` is not a binary or unicode string.
9997
"""
100-
if isinstance(bytes_or_text, _six.text_type):
98+
if isinstance(bytes_or_text, str):
10199
return bytes_or_text
102100
elif isinstance(bytes_or_text, (bytes, bytearray)):
103101
return bytes_or_text.decode(encoding)
@@ -106,10 +104,7 @@ def as_text(bytes_or_text, encoding='utf-8'):
106104

107105

108106
# Convert an object to a `str` in both Python 2 and 3.
109-
if _six.PY2:
110-
as_str = as_bytes
111-
else:
112-
as_str = as_text
107+
as_str = as_text
113108

114109

115110
def as_str_any(value):
@@ -126,7 +121,7 @@ def as_str_any(value):
126121

127122

128123
# Either bytes or text.
129-
bytes_or_text_types = (bytes, bytearray, _six.text_type)
124+
bytes_or_text_types = (bytes, bytearray, str)
130125

131126
_allowed_symbols = [
132127
'as_str',

Diff for: vertica_python/datatypes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def Binary(string):
8484
return Bytea(string)
8585

8686

87-
class VerticaType(object):
87+
class VerticaType:
8888
UNKNOWN = 4
8989
BOOL = 5
9090
INT8 = 6

Diff for: vertica_python/tests/unit_tests/test_sql_literal.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def test_default_adapters(self):
5959
self.assertEqual(cursor.object_to_sql_literal(p), "(11,22,33)")
6060

6161
def test_register_adapters(self):
62-
class Point(object):
62+
class Point:
6363
def __init__(self, x, y):
6464
self.x = x
6565
self.y = y

Diff for: vertica_python/vertica/column.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
# Data of a particular SQL data type might be transmitted in either "text" format or "binary" format.
4848
# The desired format for any column is specified by a format code.
49-
class FormatCode(object):
49+
class FormatCode:
5050
TEXT = 0
5151
BINARY = 1
5252

@@ -61,7 +61,7 @@ class ColumnTuple(NamedTuple):
6161
null_ok: bool
6262

6363

64-
class Column(object):
64+
class Column:
6565
def __init__(self, col) -> None:
6666
# Describe one query result column
6767
self.name = col['name']

Diff for: vertica_python/vertica/connection.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class _AddressEntry(NamedTuple):
142142
data: Any
143143

144144

145-
class _AddressList(object):
145+
class _AddressList:
146146
def __init__(self, host: str, port: Union[int, str],
147147
backup_nodes: List[Union[str, Tuple[str, Union[int, str]]]],
148148
logger: logging.Logger) -> None:
@@ -258,7 +258,7 @@ def _generate_session_label() -> str:
258258
)
259259

260260

261-
class Connection(object):
261+
class Connection:
262262
def __init__(self, options: Optional[Dict[str, Any]] = None) -> None:
263263
self.parameters: Dict[str, Union[str, int]] = {}
264264
self.session_id = None

Diff for: vertica_python/vertica/cursor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
DEFAULT_BUFFER_SIZE = 131072
137137

138138

139-
class Cursor(object):
139+
class Cursor:
140140
# NOTE: this is used in executemany and is here for pandas compatibility
141141
_insert_statement = re.compile(RE_BASIC_INSERT_STAT, re.U | re.I)
142142

Diff for: vertica_python/vertica/deserializer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from ..vertica.column import FormatCode
3535

3636

37-
class Deserializer(object):
37+
class Deserializer:
3838
def get_row_deserializers(self,
3939
columns: List[Column],
4040
custom_converters: Dict[int, Callable[[bytes, Dict[str, Any]], Any]],

Diff for: vertica_python/vertica/log.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
from typing import Union
4343
from ..os_utils import ensure_dir_exists
4444

45-
class VerticaLogging(object):
45+
class VerticaLogging:
4646

4747
@classmethod
4848
def setup_logging(cls, logger_name: str, logfile: str,

Diff for: vertica_python/vertica/messages/message.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
from ..messages import *
5959

6060

61-
class Message(object):
61+
class Message:
6262
__metaclass__ = ABCMeta
6363

6464
def __init__(self):

0 commit comments

Comments
 (0)