Skip to content

[CI] Add three pre-commit pygrep hooks - #12933

Open
jbampton wants to merge 4 commits into
apache:mainfrom
jbampton:add-pre-commit-pygrep-hooks
Open

[CI] Add three pre-commit pygrep hooks#12933
jbampton wants to merge 4 commits into
apache:mainfrom
jbampton:add-pre-commit-pygrep-hooks

Conversation

@jbampton

Copy link
Copy Markdown
Member

https://github.com/pre-commit/pygrep-hooks

Official hooks from pre-commit some more basic checks or tests we can run

Description

This PR...

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

https://github.com/pre-commit/pygrep-hooks

Official hooks from pre-commit some more basic checks or tests we can run
@jbampton

Copy link
Copy Markdown
Member Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@jbampton a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@codecov

codecov Bot commented Mar 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 19.78%. Comparing base (d87c804) to head (69c15b3).

Additional details and impacted files
@@            Coverage Diff            @@
##               main   #12933   +/-   ##
=========================================
  Coverage     19.78%   19.78%           
+ Complexity    19995    19993    -2     
=========================================
  Files          6371     6371           
  Lines        575909   575909           
  Branches      70509    70509           
=========================================
+ Hits         113950   113951    +1     
- Misses       449526   449529    +3     
+ Partials      12433    12429    -4     
Flag Coverage Δ
uitests 3.52% <ø> (ø)
unittests 21.06% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17311

Copilot AI lite review requested due to automatic review settings August 12, 2026 05:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds additional upstream pygrep-hooks checks to the repository’s pre-commit configuration to catch a few common Python/text pitfalls earlier in CI and local developer workflows.

Changes:

  • Add python-check-mock-methods to detect common invalid unittest.mock method usages.
  • Add python-use-type-annotations to discourage PEP 484 type comments in favor of annotations (with a targeted exclude).
  • Add text-unicode-replacement-char to forbid UTF-8 replacement characters in committed files.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@DaanHoogland
DaanHoogland requested a review from vishesh92 August 12, 2026 13:46

@DaanHoogland DaanHoogland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

clgtm

Copilot AI review requested due to automatic review settings September 9, 2026 02:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The changes are limited to CI/pre-commit configuration, with only minor wording/spelling fixes suggested for clarity.

Review details

Suppressed comments (1)

.pre-commit-config.yaml:200

  • The hook name uses the abbreviation "char" while the description spells out "character"; keeping these consistent avoids confusion.
        name: run check for no unicode replacement char
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread .pre-commit-config.yaml
Comment on lines +193 to +194
name: run check for not-real mock methods
description: Prevent common mistakes of assert mck.not_called(), assert mck.called_once_with(...) and mck.assert_called
@jbampton
jbampton requested a review from Damans227 September 9, 2026 03:13
Comment thread .pre-commit-config.yaml
- repo: https://github.com/pre-commit/pygrep-hooks
rev: 3a6eb0fadf60b3cccfd80bad9dbb6fae7e47b316 # frozen: v1.10.0
hooks:
- id: python-check-mock-methods

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this one adding anything for us right now?

Comment thread .pre-commit-config.yaml
- id: python-use-type-annotations
name: run check for type annotations not comments
description: Enforce that python3.6+ type annotations are used instead of type comments
exclude: ^scripts/vm/hypervisor/xenserver/xenserver56/InterfaceReconfigure\.py$

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why is this one file skipped? I looked and it has no type comment in it. It just has a normal sentence that starts with the word "type". So any comment written like that in future will fail and end up added to this list. Is that ok?

Comment thread .pre-commit-config.yaml
name: run check for type annotations not comments
description: Enforce that python3.6+ type annotations are used instead of type comments
exclude: ^scripts/vm/hypervisor/xenserver/xenserver56/InterfaceReconfigure\.py$
- id: text-unicode-replacement-char

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This runs over every file in the repo. Is there a chance some test data has one of these characters on purpose?

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

Labels

None yet

Projects

Status: Ready

Development

Successfully merging this pull request may close these issues.

7 participants