Skip to content

Commit dfdb958

Browse files
committed
more tweaks
1 parent 1b19bd2 commit dfdb958

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

cursorless-talon/src/csv_overrides.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from dataclasses import dataclass
44
from datetime import datetime
55
from pathlib import Path
6-
from typing import Callable, Optional, TypedDict
6+
from typing import Callable, Iterable, Optional, TypedDict
77

88
from talon import Context, Module, actions, app, fs
99

@@ -246,22 +246,20 @@ def update_dicts(
246246
raise
247247

248248
# Convert result map back to result list
249-
results = {res["list"]: {} for res in results_map.values()}
250-
values: list[SpokenFormEntry] = []
251-
for list_name, id, spoken_forms in generate_spoken_forms(
252-
list(results_map.values())
253-
):
249+
lists: ListToSpokenForms = {res["list"]: {} for res in results_map.values()}
250+
spoken_form_entries: list[SpokenFormEntry] = []
251+
for list_name, id, spoken_forms in generate_spoken_forms(results_map.values()):
254252
for spoken_form in spoken_forms:
255-
results[list_name][spoken_form] = id
256-
values.append(
253+
lists[list_name][spoken_form] = id
254+
spoken_form_entries.append(
257255
SpokenFormEntry(list_name=list_name, id=id, spoken_forms=spoken_forms)
258256
)
259257

260258
# Assign result to talon context list
261-
assign_lists_to_context(ctx, results, pluralize_lists)
259+
assign_lists_to_context(ctx, lists, pluralize_lists)
262260

263261
if handle_new_values is not None:
264-
handle_new_values(values)
262+
handle_new_values(spoken_form_entries)
265263

266264

267265
class ResultsListEntry(TypedDict):
@@ -270,7 +268,7 @@ class ResultsListEntry(TypedDict):
270268
list: str
271269

272270

273-
def generate_spoken_forms(results_list: list[ResultsListEntry]):
271+
def generate_spoken_forms(results_list: Iterable[ResultsListEntry]):
274272
for obj in results_list:
275273
value = obj["value"]
276274
key = obj["key"]
@@ -297,10 +295,10 @@ def generate_spoken_forms(results_list: list[ResultsListEntry]):
297295

298296
def assign_lists_to_context(
299297
ctx: Context,
300-
results: dict,
298+
lists: ListToSpokenForms,
301299
pluralize_lists: list[str],
302300
):
303-
for list_name, dict in results.items():
301+
for list_name, dict in lists.items():
304302
list_singular_name = get_cursorless_list_name(list_name)
305303
ctx.lists[list_singular_name] = dict
306304
if list_name in pluralize_lists:

0 commit comments

Comments
 (0)