helpers icon indicating copy to clipboard operation
helpers copied to clipboard

Fix bug in removed_blocks_storage linter

Open gpsaggese opened this issue 8 months ago • 0 comments

When I lint several files I'm hitting this problem

i lint --files="helpers/lib_tasks_find.py"

Traceback (most recent call last):
  File "/app/helpers_root/./linters/base.py", line 519, in <module>
    _main(args_)
  File "/app/helpers_root/./linters/base.py", line 497, in _main
    lints = _run_linter(file_paths, action_names, action_classes, args)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/helpers_root/./linters/base.py", line 393, in _run_linter
    cur_file_lints = _lint(
                     ^^^^^^
  File "/app/helpers_root/./linters/base.py", line 354, in _lint
    cur_action_lints = action_class.execute(file_path, pedantic)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/helpers_root/linters/action.py", line 62, in execute
    output = self._execute(file_name, pedantic)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/helpers_root/linters/action.py", line 151, in _execute
    output.extend(action.execute(file_name, pedantic))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/helpers_root/linters/action.py", line 62, in execute
    output = self._execute(file_name, pedantic)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/helpers_root/linters/amp_doc_formatter.py", line 202, in _execute
    self._restore_removed_code_blocks(file_name, _removed_code)
  File "/app/helpers_root/linters/amp_doc_formatter.py", line 171, in _restore_removed_code_blocks
    for skipped_line in removed_blocks_storage[skipped_id]:
                        ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: '4'

I've seen this problem in several files now.

Can we make this part more robust, add tests?

gpsaggese avatar Mar 29 '25 13:03 gpsaggese