Skip to content

Fix NameError in thd_analyzer when invoked as a module - #44

Merged
endolith merged 1 commit into
masterfrom
fix/thd-analyzer-sys-import
Aug 24, 2026
Merged

Fix NameError in thd_analyzer when invoked as a module#44
endolith merged 1 commit into
masterfrom
fix/thd-analyzer-sys-import

Conversation

@endolith

@endolith endolith commented Aug 23, 2026

Copy link
Copy Markdown
Owner

Problem

scripts/thd_analyzer.py called sys.exit from thd_analyzer() when no files were given, but sys was only imported under if name == 'main'. The Windows launcher (from thd_analyzer import thd_analyzer) could therefore hit NameError on the empty-invocation path.

Fix

Move import sys to module scope.

Tests

This is split out from the tests PR (#41); the launcher/empty-invocation test lives there and exercises the fixed path.

Summary by CodeRabbit

  • Refactor
    • Improved internal import organization without changing user-visible behavior.

sys was only imported under __main__, so the Windows launcher's
'from thd_analyzer import thd_analyzer' could hit NameError on the
sys.exit path for empty invocations. Import sys at module scope.

Co-authored-by: opencode <opencode@anomalyco.ai>
@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c96d5dc4-7f82-4460-9007-551ebb7f2707

📥 Commits

Reviewing files that changed from the base of the PR and between 2202b5c and 16b6870.

📒 Files selected for processing (1)
  • scripts/thd_analyzer.py

Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change moves the sys import to module scope and removes the redundant import from the __main__ block. Runtime behavior remains unchanged.

Changes

Import cleanup

Layer / File(s) Summary
Module-level sys import
scripts/thd_analyzer.py
The script adds a module-level sys import and removes the local import from the __main__ block.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to 16b68

This localized change fixes the empty-invocation failure path without introducing an actionable merge-blocking risk; it is merge-ready after normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the NameError fix in thd_analyzer, which matches the pull request's primary change.
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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 fix/thd-analyzer-sys-import

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.

@codecov

codecov Bot commented Aug 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.34%. Comparing base (2202b5c) to head (16b6870).

Files with missing lines Patch % Lines
scripts/thd_analyzer.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #44      +/-   ##
==========================================
- Coverage   80.54%   80.34%   -0.20%     
==========================================
  Files          12       12              
  Lines         406      407       +1     
==========================================
  Hits          327      327              
- Misses         79       80       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@endolith
endolith merged commit 6bfa59b into master Aug 24, 2026
9 of 11 checks passed
@endolith
endolith deleted the fix/thd-analyzer-sys-import branch August 24, 2026 00:13
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