Skip to content

chore(lint): enforce strict ruff rules and resolve tech debt - #195

Draft
NITISH-R-G wants to merge 1 commit into
mainfrom
jules-9446876100034095715-b64b31ae
Draft

chore(lint): enforce strict ruff rules and resolve tech debt#195
NITISH-R-G wants to merge 1 commit into
mainfrom
jules-9446876100034095715-b64b31ae

Conversation

@NITISH-R-G

@NITISH-R-G NITISH-R-G commented Aug 18, 2026

Copy link
Copy Markdown
Owner

This pull request significantly elevates the static analysis standards in the repository.

Changes

  1. Ruff Rules Expansion: The .ruff.toml config has been aggressively expanded from simply ignoring one error (E402) to rigorously selecting categories like UP (pyupgrade), SIM (flake8-simplify), FURB (refurb), I (isort), and several others.
  2. Technical Debt Resolution: Over 60 historical code violations that were previously masked have been successfully auto-fixed or manually corrected to ensure the codebase utilizes the standard built-ins (e.g., using min() instead of ternary checks), simplifies blocks, removes unutilized tuple unpacks, and automatically enforces a standard import sorting.
  3. Documentation: Added CYCLE_8_REPORT.md following the continuous improvement process.

PR created automatically by Jules for task 9446876100034095715 started by @NITISH-R-G

Summary by Sourcery

Enforce stricter repository-wide Ruff checks and modernize the codebase to address the violations they expose.

Enhancements:

  • Raise Ruff coverage with broader static-analysis rules and resolve the resulting code-quality issues across the repository.
  • Modernize Python typing and simplify redundant control flow, expressions, iterations, and resource handling.
  • Standardize import organization and lint-compatible annotations across application, tooling, visualization, and training code.

Documentation:

  • Add the Cycle 8 repository health report documenting linting improvements, technical debt, and follow-up priorities.

- Expanded ruff `select` array to enforce modern python standards (UP, B, C4, SIM, PLC, I, BLE, TRY, RUF, FURB, PIE, EXE, PLR).
- Resolved triggered violations across the repository, optimizing formatting, removing unused variable bindings, and converting nested logic to standard elif structures.
- Muted unavoidable false positives in `ignore` array.
- Included CYCLE_8_REPORT.md detailing this linting sprint.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9165d5e2-ff27-4c62-b0b3-04813696693c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@sourcery-ai

sourcery-ai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Reviewer's Guide

Expand Ruff lint rules to stricter sets and fix previously masked violations across the codebase, plus add a cycle health report documenting the linting improvements.

File-Level Changes

Change Details Files
Tightened Ruff configuration and standardized import/order, typing, and clamp patterns across modules.
  • Expanded .ruff.toml to select multiple rule families (UP, SIM, FURB, I, etc.) and added a curated ignore list for known exceptions.
  • Normalized import ordering and grouping (stdlib vs third-party vs local) per Ruff/isort across server, tools, and ev_grid_oracle modules.
  • Replaced custom clamp/ternary patterns with min-based or built-in clamp helpers in norm/grid/traffic utilities.
  • Modernized typing to use PEP 604 unions and concrete OrderedDict types instead of string annotations.
.ruff.toml
server/app.py
tools/generate_health_dashboard.py
ev_grid_oracle/env.py
ev_grid_oracle/parsing.py
ev_grid_oracle/oracle_agent.py
ev_grid_oracle/grid_sim.py
ev_grid_oracle/traffic.py
ev_grid_oracle/models.py
ev_grid_oracle/city_graph.py
ev_grid_oracle/road_models.py
ev_grid_oracle/scenarios.py
ev_grid_oracle/bescom_feed.py
server/road_router.py
server/role_metrics.py
tools/build_road_graph.py
tools/fetch_bangalore_roads_overpass.py
tools/build_roads_render.py
tools/fetch_osm_roads.py
viz/city_map.py
viz/record.py
viz/record_two_phase.py
training/train_grpo.ipynb
tools/road_reward_smoke.py
ev_grid_oracle/personas.py
Refactored control flow, removed unused variables, and clarified type usage to satisfy new lint rules.
  • Simplified nested if/else chains into elif branches in the Gradio demo step logic, preserving behavior but improving readability.
  • Removed unused variables (e.g., ts, timed_out, skipped) and replaced string-based type annotations with direct types.
  • Adjusted pattern-matched hashes and encodings to use default utf-8 or no explicit encoding where acceptable to lint.
  • Updated regex flags and exception handling to avoid now-disallowed aliases or noqa comments.
viz/gradio_demo.py
server/app.py
server/app.py
ev_grid_oracle/reward_hack.py
ev_grid_oracle/world_model_verifier.py
tools/fetch_bangalore_roads_overpass.py
tools/road_reward_smoke.py
Documented the cycle’s health and linting work in a new report.
  • Added CYCLE_8_REPORT.md summarizing repository health, competitor analysis, priority improvements, sprint plan, and metrics impacted by stricter linting.
CYCLE_8_REPORT.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions

Copy link
Copy Markdown

Failed to generate code suggestions for PR

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