diff --git a/README.md b/README.md index c988cd68..ced93b08 100644 --- a/README.md +++ b/README.md @@ -716,7 +716,7 @@ cur.executemany("INSERT INTO table (a, b) VALUES (%s, %s)", [[100, value]], use_ ##### Register new SQL literal adapters 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: ```python -class Point(object): +class Point: def __init__(self, x, y): self.x = x self.y = y diff --git a/requirements-dev.txt b/requirements-dev.txt index 64507bf0..1944fb8b 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,6 +1,5 @@ pytest pytest-timeout python-dateutil -six tox #kerberos diff --git a/setup.py b/setup.py index 648d16c7..8610686a 100644 --- a/setup.py +++ b/setup.py @@ -59,7 +59,6 @@ python_requires=">=3.7", install_requires=[ 'python-dateutil>=1.5', - 'six>=1.10.0' ], classifiers=[ "Development Status :: 5 - Production/Stable", diff --git a/vertica_python/compat.py b/vertica_python/compat.py index 2fe14f5a..353e2342 100644 --- a/vertica_python/compat.py +++ b/vertica_python/compat.py @@ -63,8 +63,6 @@ * `real_types` """ -import six as _six - def as_bytes(bytes_or_text, encoding='utf-8'): """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'): Raises: TypeError: If `bytes_or_text` is not a binary or unicode string. """ - if isinstance(bytes_or_text, _six.text_type): + if isinstance(bytes_or_text, str): return bytes_or_text.encode(encoding) elif isinstance(bytes_or_text, bytearray): return bytes(bytes_or_text) @@ -97,7 +95,7 @@ def as_text(bytes_or_text, encoding='utf-8'): Raises: TypeError: If `bytes_or_text` is not a binary or unicode string. """ - if isinstance(bytes_or_text, _six.text_type): + if isinstance(bytes_or_text, str): return bytes_or_text elif isinstance(bytes_or_text, (bytes, bytearray)): return bytes_or_text.decode(encoding) @@ -106,10 +104,7 @@ def as_text(bytes_or_text, encoding='utf-8'): # Convert an object to a `str` in both Python 2 and 3. -if _six.PY2: - as_str = as_bytes -else: - as_str = as_text +as_str = as_text def as_str_any(value): @@ -126,7 +121,7 @@ def as_str_any(value): # Either bytes or text. -bytes_or_text_types = (bytes, bytearray, _six.text_type) +bytes_or_text_types = (bytes, bytearray, str) _allowed_symbols = [ 'as_str', diff --git a/vertica_python/datatypes.py b/vertica_python/datatypes.py index dfd51042..e7f25155 100644 --- a/vertica_python/datatypes.py +++ b/vertica_python/datatypes.py @@ -84,7 +84,7 @@ def Binary(string): return Bytea(string) -class VerticaType(object): +class VerticaType: UNKNOWN = 4 BOOL = 5 INT8 = 6 diff --git a/vertica_python/tests/unit_tests/test_sql_literal.py b/vertica_python/tests/unit_tests/test_sql_literal.py index ca597e09..250dea01 100644 --- a/vertica_python/tests/unit_tests/test_sql_literal.py +++ b/vertica_python/tests/unit_tests/test_sql_literal.py @@ -59,7 +59,7 @@ def test_default_adapters(self): self.assertEqual(cursor.object_to_sql_literal(p), "(11,22,33)") def test_register_adapters(self): - class Point(object): + class Point: def __init__(self, x, y): self.x = x self.y = y diff --git a/vertica_python/vertica/column.py b/vertica_python/vertica/column.py index ac8691b8..24be6e75 100644 --- a/vertica_python/vertica/column.py +++ b/vertica_python/vertica/column.py @@ -46,7 +46,7 @@ # Data of a particular SQL data type might be transmitted in either "text" format or "binary" format. # The desired format for any column is specified by a format code. -class FormatCode(object): +class FormatCode: TEXT = 0 BINARY = 1 @@ -61,7 +61,7 @@ class ColumnTuple(NamedTuple): null_ok: bool -class Column(object): +class Column: def __init__(self, col) -> None: # Describe one query result column self.name = col['name'] diff --git a/vertica_python/vertica/connection.py b/vertica_python/vertica/connection.py index b3aa4b42..a49eb0c3 100644 --- a/vertica_python/vertica/connection.py +++ b/vertica_python/vertica/connection.py @@ -142,7 +142,7 @@ class _AddressEntry(NamedTuple): data: Any -class _AddressList(object): +class _AddressList: def __init__(self, host: str, port: Union[int, str], backup_nodes: List[Union[str, Tuple[str, Union[int, str]]]], logger: logging.Logger) -> None: @@ -258,7 +258,7 @@ def _generate_session_label() -> str: ) -class Connection(object): +class Connection: def __init__(self, options: Optional[Dict[str, Any]] = None) -> None: self.parameters: Dict[str, Union[str, int]] = {} self.session_id = None diff --git a/vertica_python/vertica/cursor.py b/vertica_python/vertica/cursor.py index 705334d5..8de24b71 100644 --- a/vertica_python/vertica/cursor.py +++ b/vertica_python/vertica/cursor.py @@ -136,7 +136,7 @@ DEFAULT_BUFFER_SIZE = 131072 -class Cursor(object): +class Cursor: # NOTE: this is used in executemany and is here for pandas compatibility _insert_statement = re.compile(RE_BASIC_INSERT_STAT, re.U | re.I) diff --git a/vertica_python/vertica/deserializer.py b/vertica_python/vertica/deserializer.py index d44d3887..acad4460 100644 --- a/vertica_python/vertica/deserializer.py +++ b/vertica_python/vertica/deserializer.py @@ -34,7 +34,7 @@ from ..vertica.column import FormatCode -class Deserializer(object): +class Deserializer: def get_row_deserializers(self, columns: List[Column], custom_converters: Dict[int, Callable[[bytes, Dict[str, Any]], Any]], diff --git a/vertica_python/vertica/log.py b/vertica_python/vertica/log.py index 1f2ad468..cbaaca45 100644 --- a/vertica_python/vertica/log.py +++ b/vertica_python/vertica/log.py @@ -42,7 +42,7 @@ from typing import Union from ..os_utils import ensure_dir_exists -class VerticaLogging(object): +class VerticaLogging: @classmethod def setup_logging(cls, logger_name: str, logfile: str, diff --git a/vertica_python/vertica/messages/message.py b/vertica_python/vertica/messages/message.py index 0169e80c..d572803b 100644 --- a/vertica_python/vertica/messages/message.py +++ b/vertica_python/vertica/messages/message.py @@ -58,7 +58,7 @@ from ..messages import * -class Message(object): +class Message: __metaclass__ = ABCMeta def __init__(self):