Skip to content

Fix some issues that ruff found, format with black, use consistent zoom scale#62

Merged
AlanRockefeller merged 6 commits intomainfrom
test
Mar 28, 2026
Merged

Fix some issues that ruff found, format with black, use consistent zoom scale#62
AlanRockefeller merged 6 commits intomainfrom
test

Conversation

@AlanRockefeller
Copy link
Copy Markdown
Owner

@AlanRockefeller AlanRockefeller commented Mar 28, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Title bar now reports zoom percentage using the current zoom scale.
  • Refactor

    • Highlight recovery algorithm adjusted for more consistent highlight handling.
  • Chores

    • Widespread import/test cleanup, tooling configuration (formatters/linters) added, and miscellaneous non-functional tidy-ups.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d4bd8c91-260e-4297-8a9a-0188bc36c727

📥 Commits

Reviewing files that changed from the base of the PR and between e615162 and 605cc90.

📒 Files selected for processing (1)
  • faststack/tests/check_imports.py

Walkthrough

Wide-scope import/formatting cleanup across tests and modules, a focused rewrite of highlight-recovery math, a small QML zoom-percent calculation change, tooling config added to pyproject, and refactoring of a test import-check script into functions with a CLI entrypoint.

Changes

Cohort / File(s) Summary
App surface
faststack/app.py
Removed local type aliases; renamed crop-box vars to left,top,right,bottom; simplified recycle-bin inclusion and condensed stale-record boolean expression.
Highlight recovery
faststack/imaging/math_utils.py
Rewrote _highlight_recover_linear: removed precomputed smooth mask, normalize brightness directly, apply rational compression, and gate replacements via np.where (algorithmic change).
QML UI
faststack/qml/Main.qml
Zoom percent display now uses loupe scale (zs * 100) instead of fit ratio.
Tooling / packaging
pyproject.toml
Added black/ruff to dev extras and tool configs with per-file ignores; minor comment/format edits.
Test import-check CLI
faststack/tests/check_imports.py
Replaced top-level import attempts with check_import(module_name: str) and main(); added if __name__ == "__main__": main() entrypoint.
Imaging modules
faststack/imaging/prefetch.py, .../cache.py, .../editor.py, .../metadata.py, .../orientation.py, .../turbo.py
Import reordering/formatting and small whitespace tweaks only.
I/O modules
faststack/io/sidecar.py, faststack/io/deletion.py, faststack/io/indexer.py, faststack/io/variants.py
Import reordering and minor data-structure formatting; semantics unchanged.
Thumbnail subsystem
faststack/thumbnail_view/model.py, .../prefetcher.py, .../provider.py, .../__init__.py
Removed unused imports, consolidated duplicates, minor logging-format changes; no behavior changes.
UI providers / keystrokes
faststack/ui/provider.py, faststack/ui/keystrokes.py
Grouped/reordered imports and removed duplicates; unchanged runtime behavior.
Utilities
faststack/util/executors.py, faststack/util/thumb_debug.py
Small import-order changes only.
Models & types
faststack/models.py, faststack/deletion_types.py
Minor typing/import reorderings; no API/signature changes.
Tests — bulk cleanup
faststack/tests/... (many files; see diff)
Widespread import cleanup/reordering, removed unused imports, renamed intentionally-unused locals to _-prefixed names, minor whitespace/formatting; test logic unchanged except narrower exception in one cleanup.
Test — cleanup exception
faststack/tests/test_cache_invalidation.py
Replaced bare except with except OSError during shutil.rmtree cleanup.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: fixing ruff linting issues, applying black formatting, and updating zoom scale logic in Main.qml.
Docstring Coverage ✅ Passed Docstring coverage is 83.87% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
faststack/tests/test_highlights_v2.py (1)

45-45: Consider removing the unused variable entirely.

The _srgb variable is created but never used in the test. While prefixing with _ silences the linter warning, consider removing it entirely unless it's genuinely needed for future test expansion.

🧹 Proposed removal
-        _srgb = np.ones((100, 100, 3), dtype=np.uint8) * 255
-
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@faststack/tests/test_highlights_v2.py` at line 45, Remove the unused test
variable _srgb from the test (it's created as "_srgb = np.ones((100, 100, 3),
dtype=np.uint8) * 255" in test_highlights_v2.py) — either delete that assignment
entirely or replace it with a meaningful use in the test; preferred fix: remove
the _srgb line to avoid dead code and silence the linter.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@faststack/tests/test_highlights_v2.py`:
- Line 45: Remove the unused test variable _srgb from the test (it's created as
"_srgb = np.ones((100, 100, 3), dtype=np.uint8) * 255" in test_highlights_v2.py)
— either delete that assignment entirely or replace it with a meaningful use in
the test; preferred fix: remove the _srgb line to avoid dead code and silence
the linter.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 78bd716a-9c6e-45c6-8a24-5c7f5c56d900

📥 Commits

Reviewing files that changed from the base of the PR and between 5e30def and db24ac8.

📒 Files selected for processing (37)
  • faststack/app.py
  • faststack/imaging/math_utils.py
  • faststack/imaging/prefetch.py
  • faststack/io/sidecar.py
  • faststack/qml/Main.qml
  • faststack/tests/debug_app_init.py
  • faststack/tests/debug_editor_error.py
  • faststack/tests/repro_futures_cleanup.py
  • faststack/tests/test_config_setters.py
  • faststack/tests/test_delete_worker_edge_cases.py
  • faststack/tests/test_deletion_perf_structure.py
  • faststack/tests/test_editor_lifecycle_and_safety.py
  • faststack/tests/test_editor_no_copy.py
  • faststack/tests/test_executor_shutdown.py
  • faststack/tests/test_exif_compat.py
  • faststack/tests/test_exif_orientation.py
  • faststack/tests/test_generation_aware_preview.py
  • faststack/tests/test_handle_failures_isolated.py
  • faststack/tests/test_highlights_v2.py
  • faststack/tests/test_reactive_delete.py
  • faststack/tests/test_refresh_crash.py
  • faststack/tests/test_refresh_optimization.py
  • faststack/tests/test_sidecar.py
  • faststack/tests/test_startup_opt.py
  • faststack/tests/test_startup_optimization.py
  • faststack/tests/test_thumbnail_ready_emits_datachanged.py
  • faststack/tests/test_turbo.py
  • faststack/tests/test_ui_prefetch_safety.py
  • faststack/tests/test_ui_state_recycle.py
  • faststack/tests/test_variants.py
  • faststack/tests/test_variants_logic.py
  • faststack/tests/thumbnail_view/test_model.py
  • faststack/tests/thumbnail_view/test_prefetcher_priority.py
  • faststack/tests/thumbnail_view/test_reason_tracking.py
  • faststack/tests/thumbnail_view/test_thumbnail_ready.py
  • faststack/thumbnail_view/model.py
  • faststack/thumbnail_view/prefetcher.py
💤 Files with no reviewable changes (13)
  • faststack/tests/test_refresh_optimization.py
  • faststack/tests/test_startup_opt.py
  • faststack/tests/test_config_setters.py
  • faststack/tests/test_refresh_crash.py
  • faststack/tests/thumbnail_view/test_thumbnail_ready.py
  • faststack/tests/thumbnail_view/test_reason_tracking.py
  • faststack/tests/test_handle_failures_isolated.py
  • faststack/tests/debug_editor_error.py
  • faststack/tests/test_executor_shutdown.py
  • faststack/tests/test_variants.py
  • faststack/tests/test_editor_no_copy.py
  • faststack/imaging/math_utils.py
  • faststack/tests/test_ui_state_recycle.py

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
faststack/tests/check_imports.py (1)

22-24: Path setup is invocation-directory dependent.

Using os.getcwd() on Line 23 can point to the wrong directory when run outside repo root. Prefer deriving project root from __file__ for deterministic behavior.

Proposed fix
+from pathlib import Path
 import os
 import sys
@@
-    # Add current directory to path
-    sys.path.append(os.getcwd())
+    # Add repository root to path (stable regardless of invocation cwd)
+    repo_root = Path(__file__).resolve().parents[2]
+    if str(repo_root) not in sys.path:
+        sys.path.insert(0, str(repo_root))
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@faststack/tests/check_imports.py` around lines 22 - 24, Replace the
invocation-dependent sys.path.append(os.getcwd()) with a deterministic
project-root calculation based on this script's location: compute project_root =
os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) (or adjust the
parent chain as needed) and append that path with sys.path.insert(0,
project_root) (or sys.path.append) instead of using os.getcwd(); update the
symbol sys.path.append(os.getcwd()) in tests/check_imports.py to use this
__file__-derived project_root so imports are correct regardless of invocation
directory.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@faststack/tests/check_imports.py`:
- Around line 13-18: The exception handlers inside the import loop (the except
ImportError/except Exception blocks handling imports of module_name) only print
errors so main() can still exit zero; change this to record failures and return
a non-zero exit: add a failures counter or list in the import loop,
increment/append inside both except blocks (or re-raise a SystemExit), and after
the loop in main() call sys.exit(1) (or raise SystemExit) if any failures were
recorded; also print a concise failure summary before exiting so CI fails when
imports break.

---

Nitpick comments:
In `@faststack/tests/check_imports.py`:
- Around line 22-24: Replace the invocation-dependent
sys.path.append(os.getcwd()) with a deterministic project-root calculation based
on this script's location: compute project_root =
os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) (or adjust the
parent chain as needed) and append that path with sys.path.insert(0,
project_root) (or sys.path.append) instead of using os.getcwd(); update the
symbol sys.path.append(os.getcwd()) in tests/check_imports.py to use this
__file__-derived project_root so imports are correct regardless of invocation
directory.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 62a346c8-a3a3-45d2-9b40-d42e9cf1a49d

📥 Commits

Reviewing files that changed from the base of the PR and between db24ac8 and 20b6a3f.

📒 Files selected for processing (3)
  • faststack/tests/check_imports.py
  • faststack/tests/test_cache_invalidation.py
  • pyproject.toml
✅ Files skipped from review due to trivial changes (1)
  • pyproject.toml

Comment thread faststack/tests/check_imports.py
@AlanRockefeller AlanRockefeller merged commit f65bf19 into main Mar 28, 2026
3 checks passed
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