Skip to content

Remove E402, node ARG001, and straggler noqas (PR 2 of 3)#1576

Merged
muddlebee merged 3 commits into
Tracer-Cloud:mainfrom
AniketR10:cleanup/noqa-pr2-main-imports
May 7, 2026
Merged

Remove E402, node ARG001, and straggler noqas (PR 2 of 3)#1576
muddlebee merged 3 commits into
Tracer-Cloud:mainfrom
AniketR10:cleanup/noqa-pr2-main-imports

Conversation

@AniketR10

@AniketR10 AniketR10 commented May 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #1401

Describe the changes you have made in this PR -

PR 2 of 3 - removes 9 noqas through small, targeted refactors.

app/main.py - moved app imports inside main() so load_dotenv() can stay above them without E402 suppressions (5 noqas).
app/nodes/ - added del config to the 5 LangGraph node functions whose config arg is required by the framework wrapper but unused in the body (5 ARG001 noqas).
Stragglers added by other PRs since the audit:
3 dead noqas in banner.py and errors.py — auto-removed via RUF100.
1 real ARG002 in test_llm_client.py— used del (mock matches Anthropic SDK's keyword-arg signature).


Code Understanding and AI Usage

Did you use AI assistance (ChatGPT, Claude, Copilot, etc.) to write any part of this code?

  • No, I wrote all the code myself
  • Yes, I used AI assistance (continue below)

If you used AI assistance:

  • I have reviewed every single line of the AI-generated code
  • I can explain the purpose and logic of each function/component I added
  • I have tested edge cases and understand how the code handles them
  • I have modified the AI output to follow this project's coding standards and conventions

Explain your implementation approach:

The repo had a bunch of # noqa lint suppressions across app/main.py, the LangGraph node files, and a few tests. I removed each one by fixing the underlying cause rather than relocating the suppression: in main.py I moved the app imports inside main() so they no longer need an E402 exception, and for the node functions and a test mock — where renaming unused args to _ would break frameworks that match by keyword name — I kept the original parameter and added del at the top of the body. A few stragglers added by other PRs were just dead suppressions pointing at rules the project doesn't enforce, so I deleted them. Net result: 9 fewer noqas, all lint and tests still green, no behavior change.


Checklist before requesting a review

  • I have added proper PR title and linked to the issue
  • I have performed a self-review of my code
  • I can explain the purpose of every function, class, and logic block I added
  • I understand why my changes work and have tested them thoroughly
  • I have considered potential edge cases and how my code handles them
  • If it is a core feature, I have added thorough tests
  • My code follows the project's style guidelines and conventions

Note: Please check Allow edits from maintainers if you would like us to assist in the PR.

@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

Greptile code review

This repo uses Greptile for automated review. Before merge, aim for Confidence Score: 5/5 with zero unresolved review threads — see CONTRIBUTING.md.

Run a review — add a PR comment with:

@greptile review

Give it ~30–60 seconds (sometimes longer) for results, then fix feedback and re-trigger until you reach Confidence Score: 5/5.

Optional: automate with the greploop skill.

@greptile-apps

greptile-apps Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR removes 9 # noqa lint suppressions across 9 files by fixing the underlying causes rather than perpetuating the exceptions. No behavioral changes are introduced.

  • app/main.py: load_dotenv() and all app imports are moved inside main(), so they execute in the correct order without needing E402 suppressions.
  • Node files (5): del config is added to each LangGraph node wrapper that receives a framework-injected config parameter it doesn't use, cleanly satisfying ARG001 while preserving the required keyword-argument signature.
  • banner.py, errors.py, test_llm_client.py: Dead or straggler # noqa comments are removed — BLE001 and PLC0415 are outside the project's enforced ruff rule set, and the test mock gets del api_key, timeout to fix a genuine ARG002.

Confidence Score: 5/5

Safe to merge — all changes are lint cleanup with no logic modifications.

Every changed file is a targeted noqa removal paired with the minimal code fix that satisfies the linter: deferred imports in main.py, del statements in node wrappers, and dead-comment deletions elsewhere. None of the changes alter runtime behavior, and the node signatures still satisfy LangGraph's keyword-argument injection contract.

No files require special attention.

Important Files Changed

Filename Overview
app/main.py Moves app imports and load_dotenv() inside main() to eliminate 5 E402 noqa suppressions; behavior is unchanged for normal CLI execution.
app/nodes/adapt_window/node.py Adds del config to mark the framework-required config parameter as intentionally unused, removing the ARG001 noqa.
app/nodes/extract_alert/extract_node.py Adds del config to remove ARG001 noqa; no behavioral change.
app/nodes/plan_actions/node.py Adds del config to remove ARG001 noqa; no behavioral change.
app/nodes/publish_findings/node.py Adds del config to remove ARG001 noqa; no behavioral change.
app/nodes/root_cause_diagnosis/node.py Adds del config to remove ARG001 noqa; no behavioral change.
app/cli/interactive_shell/banner.py Removes two dead BLE001 noqa comments; BLE001 is not in the project's enforced ruff rule set, so these suppressions were no-ops.
app/cli/support/errors.py Removes dead PLC0415 noqa from a lazy import; Pylint rules are not in the enforced ruff rule set, making this suppression dead.
tests/services/test_llm_client.py Adds del api_key, timeout in the mock init to remove the ARG002 noqa while preserving the keyword-arg signature required by the Anthropic SDK mock.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["python -m app.main / CLI entrypoint"] --> B["import app.main\n(only dotenv imported at module level)"]
    B --> C["main() called"]
    C --> D["load_dotenv(override=False)\n— env vars populated"]
    D --> E["Lazy imports executed\n(app.cli, app.utils.sentry_sdk, etc.)"]
    E --> F["init_sentry()"]
    F --> G["parse_args → run_investigation_cli"]

    subgraph "LangGraph Node Calls"
        H["LangGraph passes config=RunnableConfig\nas keyword arg"]
        H --> I["node_xxx(state, config=...)"]
        I --> J["del config  -- marks unused, satisfies ARG001"]
        J --> K["node body executes with state only"]
    end
Loading

Reviews (1): Last reviewed commit: "Remove ARG001/PLC0415/BLE001 noqas in no..." | Re-trigger Greptile

Comment thread app/cli/interactive_shell/banner.py Fixed
@muddlebee muddlebee merged commit f58c7d3 into Tracer-Cloud:main May 7, 2026
8 checks passed
@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

🧑‍💻 @AniketR10 has entered the contributor hall of fame. Merged. Done. Shipped. Go touch grass (then come back with another PR). 🌱


👋 Join us on Discord - OpenSRE : hang out, contribute, or hunt for features and issues. Everyone's welcome.

kespineira added a commit to kespineira/opensre that referenced this pull request May 7, 2026
Pulls in Tracer-Cloud#1576 (E402/ARG001 noqa cleanup) and Tracer-Cloud#1579 (asyncio/selector
failure handling). Conflict resolved in app/main.py: kept upstream's
refactor that defers load_dotenv + module imports into main() to drop
the E402 noqas, and reapplied this branch's `init_sentry(entrypoint=
"cli")` on top.
Davidson3556 pushed a commit to Davidson3556/opensre that referenced this pull request May 15, 2026
…ud#1576)

* Move app imports inside main() to remove E402 noqas (PR #2 of 4)

* Remove ARG001/PLC0415/BLE001 noqas in nodes and stragglers (PR Tracer-Cloud#3 of 4)

* fix: add comment on banner.py to satisfy codeQL flagging
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.

Audit and remove all Ruff #noqa suppressions; ensure tests pass

3 participants