summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVlastimil Zíma <vlastimil.zima@nic.cz>2020-07-30 03:56:39 -0400
committersqla-tester <sqla-tester@sqlalchemy.org>2020-07-30 03:56:39 -0400
commit47b51e5a4335ced29de5d751451c4fb67ad1cce5 (patch)
treed665be2b9dd38964a6ec92c55d4d77b691e0b9a8 /lib
parent3d5a64ac09b55514da6fd30f0f085348c2d10496 (diff)
downloadsqlalchemy-47b51e5a4335ced29de5d751451c4fb67ad1cce5.tar.gz
Clean python UUID imports
Fixes: #5482 All supported python versions provide 'uuid' module. Closes: #5483 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5483 Pull-request-sha: fc32498a8b639ff21d5898100592782826d2c6dd Change-Id: I8b41b811da7576f724353425dad5d6f581641b4b
Diffstat (limited to 'lib')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py12
-rw-r--r--lib/sqlalchemy/dialects/postgresql/pg8000.py7
-rw-r--r--lib/sqlalchemy/dialects/postgresql/psycopg2.py6
3 files changed, 3 insertions, 22 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index 5cef5d929..3bd7e62d5 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -992,6 +992,7 @@ E.g.::
from collections import defaultdict
import datetime as dt
import re
+from uuid import UUID as _python_UUID
from . import array as _array
from . import hstore as _hstore
@@ -1023,12 +1024,6 @@ from ...types import TEXT
from ...types import VARCHAR
-try:
- from uuid import UUID as _python_UUID # noqa
-except ImportError:
- _python_UUID = None
-
-
IDX_USING = re.compile(r"^(?:btree|hash|gist|gin|[\w_]+)$", re.I)
AUTOCOMMIT_REGEXP = re.compile(
@@ -1302,11 +1297,6 @@ class UUID(sqltypes.TypeEngine):
DBAPI.
"""
- if as_uuid and _python_UUID is None:
- raise NotImplementedError(
- "This version of Python does not support "
- "the native UUID type."
- )
self.as_uuid = as_uuid
def bind_processor(self, dialect):
diff --git a/lib/sqlalchemy/dialects/postgresql/pg8000.py b/lib/sqlalchemy/dialects/postgresql/pg8000.py
index 197d11cf4..57c8f5a9a 100644
--- a/lib/sqlalchemy/dialects/postgresql/pg8000.py
+++ b/lib/sqlalchemy/dialects/postgresql/pg8000.py
@@ -69,6 +69,7 @@ of the :ref:`psycopg2 <psycopg2_isolation_level>` dialect:
""" # noqa
import decimal
import re
+from uuid import UUID as _python_UUID
from .base import _DECIMAL_TYPES
from .base import _FLOAT_TYPES
@@ -86,12 +87,6 @@ from ... import util
from ...sql.elements import quoted_name
-try:
- from uuid import UUID as _python_UUID # noqa
-except ImportError:
- _python_UUID = None
-
-
class _PGNumeric(sqltypes.Numeric):
def result_processor(self, dialect, coltype):
if self.asdecimal:
diff --git a/lib/sqlalchemy/dialects/postgresql/psycopg2.py b/lib/sqlalchemy/dialects/postgresql/psycopg2.py
index 850e5717c..2161b24fc 100644
--- a/lib/sqlalchemy/dialects/postgresql/psycopg2.py
+++ b/lib/sqlalchemy/dialects/postgresql/psycopg2.py
@@ -466,6 +466,7 @@ from __future__ import absolute_import
import decimal
import logging
import re
+from uuid import UUID as _python_UUID
from .base import _DECIMAL_TYPES
from .base import _FLOAT_TYPES
@@ -486,11 +487,6 @@ from ... import util
from ...engine import cursor as _cursor
from ...util import collections_abc
-try:
- from uuid import UUID as _python_UUID # noqa
-except ImportError:
- _python_UUID = None
-
logger = logging.getLogger("sqlalchemy.dialects.postgresql")