Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -918,3 +918,10 @@ Inside the `on_any_event` handler of the file watcher, properties like `event_ty
Action:
Prefer direct attribute access (`event.event_type` and `event.src_path`) over `getattr` when the attribute is guaranteed to exist.
Prefer explicit slicing over `range(len())` for iterating subsets of lists. Add conditional fast-paths for expensive string operations in high-frequency event loops.
## 2024-06-01 — Safely patch code with escapes

Learning:
When writing Python scripts to patch or generate other Python code that contains backslash escape sequences (like `if '\\' in path:`), always use raw multiline strings (e.g., `patch = r'''...'''`) for the code template. Otherwise, Python will consume the escapes during string evaluation, leading to invalid syntax (e.g., `SyntaxError: unterminated string literal`) in the generated or patched file.

Action:
Ensure to use raw strings `r"""..."""` when applying patches via `run_in_bash_session` to prevent syntax errors.
13 changes: 11 additions & 2 deletions src/echo/watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,18 @@ def _is_ignored_impl(self, path: str) -> bool:
if not path:
return False

normalized_path = path.replace('\\', '/')
if '\\' in path:
path = path.replace('\\', '/')

if '/' not in path:
if path in self.simple_exact_ignores:
return True
simple_regex = self.simple_wildcard_regex
if simple_regex and simple_regex.match(path):
return True
return False

parts = normalized_path.split('/')
parts = path.split('/')
if not self.simple_exact_ignores.isdisjoint(parts):
return True

Expand Down
1 change: 0 additions & 1 deletion tests/test_perf_hotpath.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import timeit
import pytest
from echo.watcher import CommandRunnerHandler

def test_hotpath_perf():
Expand Down
1 change: 0 additions & 1 deletion tests/test_performance.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import timeit
import pytest
from echo.watcher import CommandRunnerHandler

def test_performance_is_ignored_hotpath():
Expand Down
Loading