Skip to content

Commit ba2d715

Browse files
committed
chore: update function signatures in note.py to ensure 'file' is the first parameter; adjust test cases for consistency
1 parent 963691d commit ba2d715

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

notecard/note.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def add(card, binary=None, body=None, file=None, full=None, key=None, limit=None
6363

6464

6565
@validate_card_object
66-
def changes(card, delete=None, deleted=None, file, max=None, reset=None, start=None, stop=None, tracker=None):
66+
def changes(card, file, delete=None, deleted=None, max=None, reset=None, start=None, stop=None, tracker=None):
6767
"""Use to incrementally retrieve changes within a specific Notefile.
6868
6969
Args:
@@ -153,7 +153,7 @@ def get(card, decrypt=None, delete=None, deleted=None, file=None, note=None):
153153

154154

155155
@validate_card_object
156-
def template(card, body=None, delete=None, file, format=None, length=None, port=None, verify=None):
156+
def template(card, file, body=None, delete=None, format=None, length=None, port=None, verify=None):
157157
"""By using the `note.template` request with any `.qo`/`.qos` Notefile, developers can provide the Notecard with a schema of sorts to apply to future Notes added to the Notefile. This template acts as a hint to the Notecard that allows it to internally store data as fixed-length binary records rather than as flexible JSON objects which require much more memory. Using templated Notes in place of regular Notes increases the storage and sync capability of the Notecard by an order of magnitude. Read about Working with Note Templates for additional information.
158158
159159
Args:
@@ -188,7 +188,7 @@ def template(card, body=None, delete=None, file, format=None, length=None, port=
188188

189189

190190
@validate_card_object
191-
def update(card, body=None, file, note, payload=None, verify=None):
191+
def update(card, file, note, body=None, payload=None, verify=None):
192192
"""Update a Note in a DB Notefile by its ID, replacing the existing `body` and/or `payload`.
193193
194194
Args:

scripts/generate_apis.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ def generate_function_signature(self, api: Dict[str, Any]) -> str:
199199
properties = api["properties"]
200200
required = api["required"]
201201

202+
# Separate required and optional parameters
203+
required_params = []
204+
optional_params = []
205+
202206
# Add parameters for schema properties
203207
for prop_name, _ in properties.items():
204208
if prop_name in ["req", "cmd"]: # Skip these as they're auto-generated
@@ -209,11 +213,15 @@ def generate_function_signature(self, api: Dict[str, Any]) -> str:
209213
if param_name in self.reserved_keywords:
210214
param_name = f"{param_name}_"
211215

212-
# Required parameters come first without default values
216+
# Separate required and optional parameters
213217
if prop_name in required and prop_name not in ["req", "cmd"]:
214-
params.append(f"{param_name}")
218+
required_params.append(f"{param_name}")
215219
else:
216-
params.append(f"{param_name}=None")
220+
optional_params.append(f"{param_name}=None")
221+
222+
# Add required parameters first, then optional parameters
223+
params.extend(required_params)
224+
params.extend(optional_params)
217225

218226

219227
return f"def {func_name}({', '.join(params)}):"

test/fluent_api/test_note.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
'note.add',
1111
{
1212
'file': 'data.qo',
13-
'body': {'key_a:', 'val_a', 'key_b', 42},
13+
'body': {'key_a': 'val_a', 'key_b': 42},
1414
'payload': 'ewogICJpbnRlcnZhbHMiOiI2MCwxMiwxNCIKfQ==',
1515
'sync': True
1616
},
@@ -90,7 +90,7 @@
9090
'note.template',
9191
{
9292
'file': 'my-settings.db',
93-
'body': {'key_a:', 'val_a', 'key_b', 42},
93+
'body': {'key_a': 'val_a', 'key_b': 42},
9494
'length': 42,
9595
'format': "compact"
9696
},
@@ -111,7 +111,7 @@
111111
{
112112
'file': 'my-settings.db',
113113
'note': 'my_note',
114-
'body': {'key_a:', 'val_a', 'key_b', 42},
114+
'body': {'key_a': 'val_a', 'key_b': 42},
115115
'payload': 'ewogICJpbnRlcnZhbHMiOiI2MCwxMiwxNCIKfQ=='
116116
},
117117
),

0 commit comments

Comments
 (0)