Skip to content

fix(manager): skip ignored files early to suppress spurious warnings#124

Open
TimeToBuildBob wants to merge 1 commit intoActivityWatch:masterfrom
TimeToBuildBob:fix/suppress-ignored-file-warnings
Open

fix(manager): skip ignored files early to suppress spurious warnings#124
TimeToBuildBob wants to merge 1 commit intoActivityWatch:masterfrom
TimeToBuildBob:fix/suppress-ignored-file-warnings

Conversation

@TimeToBuildBob
Copy link
Contributor

Problem

Files like aw-qt.spec (the PyInstaller spec file) are already in ignored_filenames, but the discovery loop only applied filter_modules() after building the module list. This meant non-executable files matching aw-* (e.g. aw-qt.spec on Windows) still hit the warning branch before being filtered out, resulting in:

[WARNING]: Found matching file but was not executable: C:\Users\...\aw-qt\aw-qt.spec

This confused users since it looks like an error but is actually harmless. Reported in #110.

Fix

Skip ignored_filenames at the top of the loop so they never reach the warning branch. Also hoists _filename_to_name() so it's computed once and reused.

Changes

  • _discover_modules_in_directory: early continue for ignored filenames
  • Moves name = _filename_to_name(basename) before the is_executable check

No behavior change for any legitimate module — only suppresses the spurious warning for files that were already going to be ignored.

Files like aw-qt.spec are already in ignored_filenames, but the
discovery loop only checked ignored_filenames via filter_modules
after building the module list. This meant non-executable matches
(e.g. aw-qt.spec on Windows) still triggered 'Found matching file
but was not executable' warnings before being filtered out.

Skip ignored filenames at the start of the loop so they never reach
the warning branch. Also moves the _filename_to_name() call up so
it's computed once and reused.

Fixes spurious warnings reported in ActivityWatch#110.
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 11, 2026

Greptile Summary

This PR makes a small, targeted fix to _discover_modules_in_directory in aw_qt/manager.py: it adds an early continue for filenames already present in ignored_filenames (e.g. aw-qt.spec, aw-qt.desktop) so they never reach the else warning branch that logs "Found matching file but was not executable". The fix also hoists the _filename_to_name() call so the derived name is computed once and reused.

Key changes:

  • Early continue guard added at the top of the discovery loop for ignored_filenames entries — directly addresses the spurious warning on Windows reported in Error when run aw-qt #110.
  • name = _filename_to_name(basename) moved before the is_executable check so the variable is available both for the early-exit guard and for the modules.append(...) call.
  • No functional change for any legitimate module; filter_modules() downstream still acts as a second safety net.

No issues found. The logic is correct, consistent with the existing filter_modules / ignored_filenames approach, and the pre-existing forward reference to _filename_to_name (defined after its caller) continues to work fine in Python since it is resolved at call time.

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, well-scoped fix with no behaviour change for legitimate modules.
  • The change touches exactly four lines in one function, introduces no new logic paths for valid modules, and is consistent with the existing ignored_filenames / filter_modules design. The filter_modules call in _discover_modules_bundled acts as a second safety net, so even if the new guard were accidentally removed the end result would be the same set of modules — just with the spurious warning reappearing.
  • No files require special attention.

Important Files Changed

Filename Overview
aw_qt/manager.py Moves name = _filename_to_name(basename) before the executable check and adds an early continue for ignored_filenames, suppressing the spurious WARNING log for files like aw-qt.spec without changing any other behaviour.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[glob aw-* in directory] --> B[for each match: compute basename]
    B --> C["name = _filename_to_name(basename)"]
    C --> D{name in ignored_filenames?}
    D -- yes --> E[continue ⟵ NEW early exit\nsuppresses spurious WARNING]
    D -- no --> F{is_executable AND\nstartswith 'aw-'?}
    F -- yes --> G["modules.append(Module(name, path, 'bundled'))"]
    F -- no --> H{isdir AND\nos.X_OK?}
    H -- yes --> I[recurse into subdirectory]
    H -- no --> J[logger.warning: not executable]
Loading

Last reviewed commit: f708523

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant