From 29d0eca2d1a2d8e4e46950adf95abcc37531c5e1 Mon Sep 17 00:00:00 2001 From: Gabriel Gerlero Date: Thu, 4 Apr 2024 17:17:45 -0300 Subject: [PATCH] Return self from database __enter__ method --- electrolytes/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/electrolytes/__init__.py b/electrolytes/__init__.py index d9442e9..c24bb08 100644 --- a/electrolytes/__init__.py +++ b/electrolytes/__init__.py @@ -188,11 +188,13 @@ def _save_user_constituents(self) -> None: self._user_constituents_file.write_bytes(data) self._user_constituents_dirty = False - def __enter__(self) -> None: + def __enter__(self) -> "_Database": if not self._user_constituents_lock.is_locked: self._invalidate_user_constituents() self._user_constituents_lock.acquire() + return self + def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None: try: if (