Skip to content

Commit c062d3f

Browse files
committed
Fix CLI bugs: conditional strptime and status_code() call
- Move datetime.strptime() calls inside the None-check blocks to prevent TypeError when before/after are not provided - Fix response.status_code to response.status_code() (method call, not attribute access) Closes #35
1 parent 50cf840 commit c062d3f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

executable/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ def bulk_export_to_json(
2020
before: str | None = None,
2121
after: str | None = None,
2222
):
23-
before_dt = datetime.strptime(before, DATETIME_FORMAT)
24-
after_dt = datetime.strptime(after, DATETIME_FORMAT)
2523
client = Client(api_key=API_KEY)
2624

2725
queries = []
2826
queries.append(RawQuery(query))
2927
if before is not None:
28+
before_dt = datetime.strptime(before, DATETIME_FORMAT)
3029
before_dt_field = UpdateDateField(
3130
before_dt, operator=Operator.StrictlyGreater
3231
)
3332
queries.append(MustQuery(before_dt_field))
3433
if after is not None:
34+
after_dt = datetime.strptime(after, DATETIME_FORMAT)
3535
after_dt_field = UpdateDateField(
3636
after_dt, operator=Operator.StrictlySmaller
3737
)
@@ -46,7 +46,7 @@ def bulk_export_to_json(
4646
else:
4747
raise Exception(
4848
"API error (code = %d, message = %s)"
49-
% (response.status_code, response.json())
49+
% (response.status_code(), response.json())
5050
)
5151

5252

0 commit comments

Comments
 (0)