Skip to content

Commit 18d65ac

Browse files
tzarcChris Trotter
authored andcommitted
[CLI] Remove duplicates from search results (qmk#22528)
1 parent a9753b9 commit 18d65ac

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/python/qmk/build_targets.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ def __str__(self):
3131
def __repr__(self):
3232
return f'BuildTarget(keyboard={self.keyboard}, keymap={self.keymap})'
3333

34+
def __eq__(self, __value: object) -> bool:
35+
if not isinstance(__value, BuildTarget):
36+
return False
37+
return self.__repr__() == __value.__repr__()
38+
39+
def __ne__(self, __value: object) -> bool:
40+
return not self.__eq__(__value)
41+
42+
def __hash__(self) -> int:
43+
return self.__repr__().__hash__()
44+
3445
def configure(self, parallel: int = None, clean: bool = None, compiledb: bool = None) -> None:
3546
if parallel is not None:
3647
self._parallel = parallel

lib/python/qmk/search.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def _filter_keymap_targets(target_list: List[Tuple[str, str]], filters: List[str
122122
"""
123123
if len(filters) == 0:
124124
cli.log.info('Preparing target list...')
125-
targets = list(parallel_map(_construct_build_target_kb_km, target_list))
125+
targets = list(set(parallel_map(_construct_build_target_kb_km, target_list)))
126126
else:
127127
cli.log.info('Parsing data for all matching keyboard/keymap combinations...')
128128
valid_keymaps = [(e[0], e[1], dotty(e[2])) for e in parallel_map(_load_keymap_info, target_list)]
@@ -183,7 +183,7 @@ def f(e):
183183

184184
cli.log.info('Preparing target list...')
185185
valid_keymaps = [(e[0], e[1], e[2].to_dict() if isinstance(e[2], Dotty) else e[2]) for e in valid_keymaps] # need to convert dotty_dict back to dict because it doesn't survive parallelisation
186-
targets = list(parallel_map(_construct_build_target_kb_km_json, list(valid_keymaps)))
186+
targets = list(set(parallel_map(_construct_build_target_kb_km_json, list(valid_keymaps))))
187187

188188
return targets
189189

0 commit comments

Comments
 (0)