Skip to content

Conversation

@naaa760
Copy link
Contributor

@naaa760 naaa760 commented Dec 12, 2025

What

  • Add a ready-to-use threading guardrails preset (docs/assets/threading-guardrails.yaml) using diff-aware validators (file_patterns + require/forbidden regex).

  • Add a short guide (docs/getting-started/diff-rule-presets.md) explaining how to apply these rules even if the watchflow.dev form blocks diff rules.

  • Link the guide in the MkDocs nav.

Why

  • Makes diff-based rules immediately usable for maintainers (and Stelios’s students) without touching code, and provides a fallback when the site UI filters pattern rules.

Testing

  • Docs-only change; reviewed YAML/schema for supported fields.

@naaa760 naaa760 requested a review from dkargatzis as a code owner December 12, 2025 05:20
@gemini-code-assist
Copy link

Summary of Changes

Hello @naaa760, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the documentation by providing practical, ready-to-use diff-aware rule presets for Python threading guardrails. It aims to simplify the adoption of best practices for threading by offering pre-configured rules and clear instructions on how to implement them, even when facing potential UI limitations in rule application platforms.

Highlights

  • New Diff Rule Presets: Introduced a new YAML file (docs/assets/threading-guardrails.yaml) containing ready-to-use diff-aware rules for Python threading best practices, such as preferring ThreadPoolExecutor, requiring locks, using queue.Queue for communication, and limiting max_workers.
  • New Documentation Guide: Added a new guide (docs/getting-started/diff-rule-presets.md) explaining how to apply these diff-aware rules, including instructions for using them with watchflow.dev and providing a fallback method if the UI filters pattern rules.
  • Documentation Navigation Update: Updated the mkdocs.yml configuration to include the new 'Diff Rule Presets' guide in the 'Getting Started' section of the documentation navigation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

❌ Your project status has failed because the head coverage (32.0%) is below the target coverage (80.0%). You can increase the head coverage or adjust the target coverage.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@           Coverage Diff           @@
##            main     #29     +/-   ##
=======================================
+ Coverage   24.7%   32.0%   +7.2%     
=======================================
  Files         79      85      +6     
  Lines       4497    4993    +496     
=======================================
+ Hits        1115    1601    +486     
- Misses      3382    3392     +10     

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a518bcb...eadf244. Read the comment docs.

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

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a valuable set of preset rules for enforcing Python threading best practices, along with corresponding documentation. This is a great initiative. However, the current implementation of several rules in docs/assets/threading-guardrails.yaml is likely to produce a high volume of false positives, which could make them impractical. Specifically, the rules using require_patterns are too broad as they apply to all modified Python files. Additionally, the regular expression for limiting max_workers is incomplete. I have provided specific comments and suggestions to address these issues and improve the usability of these presets.

Comment on lines 10 to 11
require_patterns:
- "concurrent\\.futures\\.ThreadPoolExecutor"

Choose a reason for hiding this comment

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

high

The require_patterns clause makes this rule overly broad. It will enforce the presence of concurrent.futures.ThreadPoolExecutor in any modified Python file, even those unrelated to threading, leading to a high number of false positives. To achieve the goal of preferring ThreadPoolExecutor over threading.Thread, simply forbidding threading.Thread is a more effective and less noisy approach. Consider removing the require_patterns block to make the rule more targeted and practical.

Comment on lines 19 to 20
require_patterns:
- "threading\\.Lock"

Choose a reason for hiding this comment

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

high

This rule is too broad and will likely create a lot of noise. It requires threading.Lock to be present in any modified Python file, regardless of whether it uses threading. This will trigger for any change, such as fixing a typo in a comment in a file that doesn't use threading. For this rule to be effective, it should be conditional on the presence of threading code (e.g., ThreadPoolExecutor). In its current form, this rule is impractical due to the high potential for false positives.

Comment on lines 28 to 29
require_patterns:
- "queue\\.Queue"

Choose a reason for hiding this comment

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

high

Similar to the rule for threading.Lock, this rule is too broad. It requires queue.Queue in every modified Python file, which will lead to many false positives. This check should ideally be triggered only when threading is being used in the file to be useful and avoid excessive noise.

parameters:
file_patterns: ["**/*.py"]
forbidden_patterns:
- "ThreadPoolExecutor\\(max_workers\\s*=\\s*(1[1-9]|[2-9][0-9])"

Choose a reason for hiding this comment

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

high

The regular expression to detect max_workers greater than 10 is incomplete. It currently matches values from 11 to 99, but it will miss any value of 100 or greater. To correctly match all integers greater than 10, the regex should be updated to cover numbers with three or more digits.

        - "ThreadPoolExecutor\\(max_workers\\s*=\\s*(1[1-9]|[2-9]\\d|\\d{3,})"

@dkargatzis dkargatzis merged commit 9a6fbb7 into warestack:main Dec 12, 2025
4 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.

3 participants