From 9cbdb3772c5f8c93ad6515843d223a1afc5f604d Mon Sep 17 00:00:00 2001 From: Friedrich Lindenberg Date: Mon, 6 Apr 2020 22:56:35 +0200 Subject: [PATCH] A bit of cleanup --- dataset/types.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/dataset/types.py b/dataset/types.py index 904ffa9..d30d3c1 100644 --- a/dataset/types.py +++ b/dataset/types.py @@ -2,6 +2,7 @@ from datetime import datetime, date from sqlalchemy import Integer, UnicodeText, Float, BigInteger from sqlalchemy import Boolean, Date, DateTime, Unicode, JSON +from sqlalchemy.dialects.postgresql import JSONB from sqlalchemy.types import TypeEngine @@ -16,25 +17,21 @@ class Types(object): date = Date datetime = DateTime - def __init__(self, dialect = None): + def __init__(self, dialect=None): self._dialect = dialect @property def json(self): if self._dialect is not None and self._dialect == 'postgresql': - from sqlalchemy.dialects.postgresql import JSONB return JSONB return JSON - def guess(self, sample, dialect = None): + def guess(self, sample): """Given a single sample, guess the column type for the field. If the sample is an instance of an SQLAlchemy type, the type will be used instead. """ - if dialect is not None: - self._dialect = dialect - if isinstance(sample, TypeEngine): return sample if isinstance(sample, bool):