Skip to content

Commit

Permalink
Tiny API tweaks
Browse files Browse the repository at this point in the history
Use the empty string as default data source name: it makes typing a
tiny bit easier and reflects what other DB-ABI implementations use.

Mark additional arguments to the attach() function as keyword only.
  • Loading branch information
dnicolodi committed Jan 11, 2025
1 parent df1e68c commit b6ef817
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions beanquery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ def connect(dsn, **kwargs):


class Connection:
def __init__(self, dsn=None, **kwargs):
def __init__(self, dsn='', **kwargs):
self.tables = {'': tables.NullTable()}
self.options = {}
self.errors = []
if dsn is not None:
if dsn:
self.attach(dsn, **kwargs)

def attach(self, dsn, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion beanquery/sources/beancount.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
TABLES = [query_env.EntriesTable, query_env.PostingsTable]


def attach(context, dsn, entries=None, errors=None, options=None):
def attach(context, dsn, *, entries=None, errors=None, options=None):
filename = urlparse(dsn).path
if filename:
entries, errors, options = loader.load_file(filename)
Expand Down

0 comments on commit b6ef817

Please sign in to comment.