Skip to content

Commit

Permalink
test(lazyconnect): explicit None to connect
Browse files Browse the repository at this point in the history
  • Loading branch information
Saul Pwanson committed Nov 24, 2021
1 parent e94f511 commit 3193412
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions ibis/backends/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@ def name(self) -> str:
Name of the backend, for example 'sqlite'.
"""

def connect(self, connection_string, **options):
def connect(self, *args, **options):
"""
Return client object, ready to connect (via do_connect()) to given *connection_string* with given *options*.
"""
new_backend = self.__class__()
new_backend.con_str = connection_string
new_backend.con_args = args
new_backend.con_options = options
new_backend.do_connect(connection_string, **options)
new_backend.do_connect(*args, **options)
return new_backend

@abc.abstractmethod
Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/mysql/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def do_connect(
)

self.database_name = alchemy_url.database
super().do_connect(self, sqlalchemy.create_engine(alchemy_url))
super().do_connect(sqlalchemy.create_engine(alchemy_url))

@contextlib.contextmanager
def begin(self):
Expand Down
4 changes: 2 additions & 2 deletions ibis/backends/sqlite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ def __getstate__(self):
database_class=self.database_class,
compiler=self.compiler,
database_name=self.database_name,
con_str=self.con_str,
con_args=self.con_args,
con_options=self.con_options,
)

@property
def con(self):
if self._con is None:
self.do_connect(self.con_str, **self.con_options)
self.do_connect(*self.con_args, **self.con_options)
return self._con

@con.setter
Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/sqlite/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_list_tables(con):


def test_attach_file(dbpath):
client = Backend().connect()
client = Backend().connect(None)

client.attach('foo', dbpath)
client.attach('bar', dbpath)
Expand Down

0 comments on commit 3193412

Please sign in to comment.