Skip to content

Commit 234cf21

Browse files
author
Karl Wooster
committed
fix(cli): update how settings are retrieved for cli
need to add tests for cli since that is where most people will use the code
1 parent 3f0d2e3 commit 234cf21

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/ynamazon/cli/cli.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from ynamazon.settings import ConfigFile, SecretApiKey, SecretBudgetId, get_settings
2020
from ynamazon.ynab_transactions import (
2121
TempYnabTransaction,
22+
get_default_ynab_config,
2223
get_ynab_transactions,
2324
update_ynab_transaction,
2425
)
@@ -227,15 +228,14 @@ def new_ynamazon( # noqa: C901
227228
}
228229
)
229230

230-
ynab_config = Configuration(
231-
access_token=cli_settings.ynab_api_key.get_secret_value()
232-
)
231+
ynab_config = get_default_ynab_config()
233232

234233
try:
235234
ynab_trans, amazon_with_memo_payee = get_ynab_transactions(
236235
configuration=ynab_config,
237-
budget_id=cli_settings.ynab_budget_id.get_secret_value(),
236+
budget_id=cli_settings.get_secret_value("ynab_budget_id"),
238237
)
238+
console.print(f"[bold green]Found {len(ynab_trans)} transactions.[/]")
239239
except YnabSetupError as e:
240240
console.print(f"[bold red]get_settings() error: {e}[/]")
241241
console.print(

src/ynamazon/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
from .exceptions import YnabSetupError
1717
from .settings import get_settings
18-
from .ynab_transactions import default_configuration as ynab_configuration
1918
from .ynab_transactions import (
19+
get_default_ynab_config,
2020
get_ynab_transactions,
2121
markdown_formatted_link,
2222
markdown_formatted_title,
@@ -113,7 +113,7 @@ def process_transactions(
113113
) -> None:
114114
"""Match YNAB transactions to Amazon Transactions and optionally update YNAB Memos."""
115115
amazon_config = amazon_config or AmazonConfig()
116-
ynab_config = ynab_config or ynab_configuration
116+
ynab_config = ynab_config or get_default_ynab_config()
117117
budget_id = budget_id or get_settings().ynab_budget_id.get_secret_value()
118118

119119
console = Console()

0 commit comments

Comments
 (0)