From 7ca497a8f5be24c127946813e3052a19b48be1b3 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Tue, 25 Oct 2022 13:14:41 -0700 Subject: [PATCH] repr improvements, refs #503 --- sqlite_utils/db.py | 3 ++- sqlite_utils/utils.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sqlite_utils/db.py b/sqlite_utils/db.py index 27c46b0af..0d9eaedd8 100644 --- a/sqlite_utils/db.py +++ b/sqlite_utils/db.py @@ -308,6 +308,7 @@ def __init__( assert (filename_or_conn is not None and (not memory and not memory_name)) or ( filename_or_conn is None and (memory or memory_name) ), "Either specify a filename_or_conn or pass memory=True" + self.conn = None if memory_name: uri = "file:{}?mode=memory&cache=shared".format(memory_name) self.conn = sqlite3.connect( @@ -3534,7 +3535,7 @@ class View(Queryable): def exists(self): return True - def __repr__(self): + def __repr__(self) -> str: return "".format( self.name, ", ".join(c.name for c in self.columns) ) diff --git a/sqlite_utils/utils.py b/sqlite_utils/utils.py index 8916c46e0..4e5bbccef 100644 --- a/sqlite_utils/utils.py +++ b/sqlite_utils/utils.py @@ -392,7 +392,7 @@ def test_float(self, value): except (ValueError, TypeError): return False - def __repr__(self): + def __repr__(self) -> str: return self.guessed_type + ": possibilities = " + repr(self.couldbe) @property