Skip to content

Fix extract_todos_structured.py behavior - #377

Open
google-labs-jules[bot] wants to merge 7 commits into
mainfrom
fix-extract-todos-7795192670709366839
Open

Fix extract_todos_structured.py behavior#377
google-labs-jules[bot] wants to merge 7 commits into
mainfrom
fix-extract-todos-7795192670709366839

Conversation

@google-labs-jules

@google-labs-jules google-labs-jules Bot commented Jul 9, 2026

Copy link
Copy Markdown

This pull request addresses several issues with the extract_todos_structured.py tool. It adds .Jules to the list of excluded directories to speed up traversal and avoid indexing instructions as code logic. The script was also scanning its own source code and incorrectly identifying the matching regexes themselves as TODOs, so I implemented a check to skip scanning extract_todos_structured.py. Furthermore, it now extracts the owner metadata field from correctly structured TODOs, such as those written by Sentinel (TODO(priority=Low, complexity=Medium, owner=infra):...), while falling back to older patterns if owner is missing.


PR created automatically by Jules for task 7795192670709366839 started by @MasumRab

Summary by Sourcery

Improve structured TODO extraction behavior and metadata handling in the todo scanning script.

Bug Fixes:

  • Prevent the todo extractor from scanning its own source file and misidentifying regex definitions as TODOs.
  • Exclude the .Jules directory from traversal to avoid indexing instruction content and speed up scanning.

Enhancements:

  • Extend structured TODO parsing to support an owner field while preserving compatibility with the previous priority/complexity-only format.
  • Include owner metadata in the emitted TODO records with a sensible default when not present.

…t self-parsing

- Added `.Jules` to exclusions to prevent recursively parsing agent files.
- Added self-skip check in loop so `extract_todos_structured.py` is ignored and its regexes are not parsed.
- Upgraded regex logic to support the optional `owner` property in structured TODOs.
@google-labs-jules

Copy link
Copy Markdown
Author

👋 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.

@trunk-io

trunk-io Bot commented Jul 9, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@sourcery-ai

sourcery-ai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates the structured TODO extraction script to better control directory traversal, avoid self-scanning, and support an owner field in structured TODO metadata while maintaining backward compatibility with the previous format.

File-Level Changes

Change Details Files
Tightened directory traversal and prevented the script from scanning its own source file.
  • Added '.Jules' to the set of excluded directories for os.walk
  • Filtered out the script file name 'extract_todos_structured.py' from processing during file iteration
scripts/extract_todos_structured.py
Enhanced structured TODO parsing to support an owner field while remaining compatible with older TODO formats.
  • Updated the documented structured TODO format comment to include owner metadata
  • Introduced an owner variable with default value 'Unknown' in the parser
  • Changed the primary regex to parse priority, complexity, and owner from structured TODOs
  • Added a fallback regex that parses only priority and complexity for older TODO entries
  • Extended the TODO record dictionary to include the owner field
scripts/extract_todos_structured.py

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

@sourcery-ai sourcery-ai 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.

Hey - I've left some high level feedback:

  • When skipping extract_todos_structured.py, you currently rely on the filename only; if this script is ever renamed or duplicated under a different name, it will be scanned again—consider skipping by full path or by a clearer marker to make the exclusion more robust.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- When skipping `extract_todos_structured.py`, you currently rely on the filename only; if this script is ever renamed or duplicated under a different name, it will be scanned again—consider skipping by full path or by a clearer marker to make the exclusion more robust.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Fixes a SonarCloud warning about inefficient regex in loops.
Fixes a SonarCloud warning about inefficient regex in loops.
Fixes a SonarCloud warning about inefficient regex in loops.
@MasumRab
MasumRab enabled auto-merge (squash) July 9, 2026 08:34
@MasumRab

MasumRab commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Hey - I've left some high level feedback:

  • When skipping extract_todos_structured.py, you currently rely on the filename only; if this script is ever renamed or duplicated under a different name, it will be scanned again—consider skipping by full path or by a clearer marker to make the exclusion more robust.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- When skipping `extract_todos_structured.py`, you currently rely on the filename only; if this script is ever renamed or duplicated under a different name, it will be scanned again—consider skipping by full path or by a clearer marker to make the exclusion more robust.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@jules

@google-labs-jules

Copy link
Copy Markdown
Author

Hey - I've left some high level feedback:

  • When skipping extract_todos_structured.py, you currently rely on the filename only; if this script is ever renamed or duplicated under a different name, it will be scanned again—consider skipping by full path or by a clearer marker to make the exclusion more robust.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- When skipping `extract_todos_structured.py`, you currently rely on the filename only; if this script is ever renamed or duplicated under a different name, it will be scanned again—consider skipping by full path or by a clearer marker to make the exclusion more robust.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@jules

Good call! I've updated the script to use Path(__file__).resolve() to reliably compare the current file against the ones being iterated over, which will prevent it from parsing its own Regex patterns regardless of whether it's renamed or moved.

google-labs-jules Bot and others added 3 commits July 9, 2026 08:39
Addresses code review feedback indicating that excluding solely by filename 'extract_todos_structured.py' is fragile. Compares file resolutions against Path(__file__).resolve() to ensure only this specific file is ignored regardless of its final name or directory placement.
Addresses a SonarCloud warning about maintainability (too much nesting) by breaking early when files are irrelevant or lines don't contain 'TODO'.
@sonarqubecloud

Copy link
Copy Markdown

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant