qmk_firmware/lib/python/qmk
Sergey Vlasov 1411c79aef
qmk find: Fix handling of functions in filters (#21090)
Functions in filters did not work properly except when used in the last
(or only) filter.  The problem was caused by the peculiarity of the
`lambda` behavior in Python — any variables from the outer scope are
captured only by reference, therefore any subsequent reassignment of
those variables is propagated to all lambdas created earlier in the same
scope.  Together with the laziness of `filter()` (it returns an iterator
which performs filtering on demand) this resulted in all function
filters using the values of the `key` and `value` variables which
correspond to the last filter in the sequence, therefore the result of
filtering was wrong if some filter with a function was not the last one
in the sequence.

Apparently the shortest way to make a Python lambda capture some
variables by value is to add arguments with default values for such
variables (default values are evaluated when the lambda is created, and
any subsequent reassignments in the outer scope no longer changes them).
This makes filters with functions work properly even when such filters
are not at the last position in the sequence.
2023-05-30 19:24:19 +01:00
..
cli Fix up qmk find when not specifying filters. (#21059) 2023-05-27 13:23:07 +10:00
tests Update json2c to use dump_lines (#21013) 2023-05-22 07:03:59 +01:00
__init__.py
c_parse.py Merge remote-tracking branch 'origin/master' into develop 2023-03-24 02:47:22 +00:00
commands.py Append user variables to the end of make command (#20177) 2023-04-03 15:20:39 +10:00
comment_remover.py
constants.py
converter.py
datetime.py
decorators.py
errors.py
flashers.py Allow CLI to flash .uf2 files (#19462) 2023-01-01 15:51:29 +11:00
git.py Add commit info to version.h (#19542) 2023-02-02 18:23:27 +00:00
importers.py qmk format-json: Expose full key path and respect sort_keys (#20836) 2023-05-20 22:15:05 +10:00
info.py qmk info: account for ISO enter when calculating layout X offset (#20325) 2023-04-04 01:15:35 +01:00
json_encoders.py qmk format-json: Expose full key path and respect sort_keys (#20836) 2023-05-20 22:15:05 +10:00
json_schema.py Reallocate user/kb keycode ranges (#19907) 2023-02-23 09:50:09 +11:00
keyboard.py Replace list_keyboards.sh with CLI calls (#19485) 2023-01-03 14:15:29 +11:00
keycodes.py Reallocate user/kb keycode ranges (#19907) 2023-02-23 09:50:09 +11:00
keymap.py CLI: Improve keymap folder resolution (#20981) 2023-05-19 16:05:43 +10:00
makefile.py qmk find: usability improvements (#20440) 2023-05-20 22:14:43 +10:00
math.py
painter.py [Bugfix + Refactor] qmk painter-convert-graphics (#19994) 2023-05-26 03:07:06 +01:00
painter_qff.py
painter_qgf.py [QP] Fix up delta frame boundaries (#20296) 2023-03-31 08:41:11 +11:00
path.py CLI: Improve keymap folder resolution (#20981) 2023-05-19 16:05:43 +10:00
search.py qmk find: Fix handling of functions in filters (#21090) 2023-05-30 19:24:19 +01:00
submodules.py Report submodule status when not valid work-tree (#19474) 2023-01-03 09:00:29 +11:00