Re: [PATCH] bindings/python-cffi: search for config by default

2022-01-08 Thread Floris Bruynooghe
On Sat 08 Jan 2022 at 12:19 -0400, David Bremner wrote:

> The previous (pre-0.34.2) constructor searched for a config file but
> only if the database path was not specified, and only to retrieve
> database.path. Neither of the available options (CONFIG.SEARCH or
> CONFIG.NONE) matches this semantics exactly, but CONFIG.SEARCH causes
> less breakage for people who relied on the old behaviour to set their
> database.path [1]. Since it also seems like the friendlier option in
> the long run, this commit switches to CONFIG.SEARCH as default.
>
> [1]: id:87fsqijx7u@metapensiero.it
> ---
>  bindings/python-cffi/notmuch2/_database.py  | 2 +-
>  bindings/python-cffi/tests/test_database.py | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/bindings/python-cffi/notmuch2/_database.py 
> b/bindings/python-cffi/notmuch2/_database.py
> index 14a8f15c..d7485b4d 100644
> --- a/bindings/python-cffi/notmuch2/_database.py
> +++ b/bindings/python-cffi/notmuch2/_database.py
> @@ -139,7 +139,7 @@ class Database(base.NotmuchObject):
>  path = os.fsencode(path)
>  return path
>  
> -def __init__(self, path=None, mode=MODE.READ_ONLY, config=CONFIG.EMPTY):
> +def __init__(self, path=None, mode=MODE.READ_ONLY, config=CONFIG.SEARCH):
>  if isinstance(mode, str):
>  mode = self.STR_MODE_MAP[mode]
>  self.mode = mode
> diff --git a/bindings/python-cffi/tests/test_database.py 
> b/bindings/python-cffi/tests/test_database.py
> index 9b3219c0..473723d5 100644
> --- a/bindings/python-cffi/tests/test_database.py
> +++ b/bindings/python-cffi/tests/test_database.py
> @@ -13,7 +13,7 @@ import notmuch2._message as message
>  
>  @pytest.fixture
>  def db(maildir):
> -with dbmod.Database.create(maildir.path) as db:
> +with dbmod.Database.create(maildir.path, 
> config=notmuch2.Database.CONFIG.SEARCH) as db:
>  yield db

LGTM
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH] bindings/python-cffi: search for config by default

2022-01-08 Thread David Bremner
The previous (pre-0.34.2) constructor searched for a config file but
only if the database path was not specified, and only to retrieve
database.path. Neither of the available options (CONFIG.SEARCH or
CONFIG.NONE) matches this semantics exactly, but CONFIG.SEARCH causes
less breakage for people who relied on the old behaviour to set their
database.path [1]. Since it also seems like the friendlier option in
the long run, this commit switches to CONFIG.SEARCH as default.

[1]: id:87fsqijx7u@metapensiero.it
---
 bindings/python-cffi/notmuch2/_database.py  | 2 +-
 bindings/python-cffi/tests/test_database.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/bindings/python-cffi/notmuch2/_database.py 
b/bindings/python-cffi/notmuch2/_database.py
index 14a8f15c..d7485b4d 100644
--- a/bindings/python-cffi/notmuch2/_database.py
+++ b/bindings/python-cffi/notmuch2/_database.py
@@ -139,7 +139,7 @@ class Database(base.NotmuchObject):
 path = os.fsencode(path)
 return path
 
-def __init__(self, path=None, mode=MODE.READ_ONLY, config=CONFIG.EMPTY):
+def __init__(self, path=None, mode=MODE.READ_ONLY, config=CONFIG.SEARCH):
 if isinstance(mode, str):
 mode = self.STR_MODE_MAP[mode]
 self.mode = mode
diff --git a/bindings/python-cffi/tests/test_database.py 
b/bindings/python-cffi/tests/test_database.py
index 9b3219c0..473723d5 100644
--- a/bindings/python-cffi/tests/test_database.py
+++ b/bindings/python-cffi/tests/test_database.py
@@ -13,7 +13,7 @@ import notmuch2._message as message
 
 @pytest.fixture
 def db(maildir):
-with dbmod.Database.create(maildir.path) as db:
+with dbmod.Database.create(maildir.path, 
config=notmuch2.Database.CONFIG.SEARCH) as db:
 yield db
 
 
-- 
2.34.1

___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org