Skip to content

STYLE: Adding precommit hook and workflow for checking code quality - #302

Merged
Jahnvi Thakkar (jahnvi480) merged 4 commits into
mainfrom
jahnvi/linting_prehook
Oct 5, 2026
Merged

Jahnvi Thakkar (jahnvi480) merged 4 commits into
mainfrom
jahnvi/linting_prehook

Conversation

@jahnvi480

@jahnvi480 Jahnvi Thakkar (jahnvi480) commented Oct 28, 2025 •

Copy link
Copy Markdown
Contributor

Work Item / Issue Reference

AB#33454


Summary

Refresh the pre-commit implementation against current main so local formatting
checks match the repository's existing blocking CI rule: Black.

  • Add a pinned Black hook that formats staged Python and type-stub files under
    mssql_python and tests, stopping commits when fixes need review and restaging.
  • Install a pre-push hook that checks both directories in full without modifying
    files. Run that same hook and pinned formatter version in the existing lint
    workflow.
  • Keep Flake8, Pylint, mypy, clang-format, and cpplint informational. Replace the
    earlier draft's separate Pylint/cpplint blocking workflow rather than introduce
    new lint thresholds or change C++ formatting policy.
  • Add isolated lint-tool installation through requirements-lint.txt, install both
    hooks automatically in devcontainers, and document setup for new and existing
    clones.
  • Add repository-wide Copilot guidance to detect missing local hook setup, install it
    in the development environment, and run the shared formatting check before pushes
    and PRs. Pulling alone does not execute setup; Copilot acts during an editing task.
  • Run the lint workflow on every PR, including documentation-only changes, so a
    required lint status check is not skipped by path filters.

Local hooks cannot prevent PR creation and can be bypassed. Maintainers must
require Linting Summary in branch protection/rulesets to block merging
formatting failures; this PR does not modify repository protection settings.

Copilot AI review requested due to automatic review settings October 28, 2025 07:27
@github-actions github-actions Bot added the pr-size: medium Moderate update size label Oct 28, 2025

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

This pull request adds automated code quality enforcement by introducing pre-commit hooks and GitHub Actions workflows to check Python and C++ code against linting standards.

Key changes:

  • GitHub Actions workflow for automatic linting checks on pull requests with configurable thresholds
  • Pre-commit hooks for local linting enforcement before commits
  • Configuration files defining linting rules, disabled checks, and error thresholds for both Python (pylint) and C++ (cpplint)

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

File Description
.github/workflows/code-quality-check.yml Implements CI workflow to run pylint and cpplint on PRs, report status, and post results as comments
.pre-commit-config.yml Configures pre-commit hooks for pylint and cpplint with specified arguments and file exclusions
pyproject.toml Defines pylint configuration including disabled checks, minimum score threshold of 8.5, and max line length
cpplint.cfg Sets C++ linting rules including line length limit and filtered checks

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .pre-commit-config.yml Outdated
Comment thread .github/workflows/code-quality-check.yml Outdated
Comment thread .github/workflows/code-quality-check.yml Outdated
@github-actions

github-actions Bot commented Oct 28, 2025 •

Copy link
Copy Markdown

📊 Code Coverage Report

🔥 Diff Coverage

100%


🎯 Overall Coverage

85%


📈 Total Lines Covered: 9447 out of 11094
📁 Project: mssql-python


Diff Coverage

Diff: main...HEAD, staged and unstaged changes

No lines with coverage information in this diff.


📋 Files Needing Attention

📉 Files with overall lowest coverage (click to expand)
mssql_python.pybind.performance_counter.hpp: 0.7%
mssql_python.pybind.logger_bridge.cpp: 57.9%
mssql_python.pybind.ddbc_bindings.h: 62.6%
mssql_python.pybind.logger_bridge.hpp: 70.8%
mssql_python.pybind.connection.connection_pool.cpp: 82.9%
mssql_python.pybind.connection.connection.cpp: 83.1%
mssql_python.logging.py: 86.2%
mssql_python.pooling.py: 90.1%
mssql_python.pybind.fetch_temporal.hpp: 92.1%
mssql_python.cursor.py: 92.5%

🔗 Quick Links

⚙️ Build Summary 📋 Coverage Details

View Azure DevOps Build

Browse Full Coverage Report

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.

only minor change required. rest all looks good

Copilot AI balanced review requested due to automatic review settings September 30, 2026 13:48
@github-actions github-actions Bot added pr-size: large Substantial code update and removed pr-size: medium Moderate update size labels Sep 30, 2026
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

PR Performance Report

✅ No regression detected

No consistent slowdowns detected across all 2 environments.

0 IMPROVEMENTS 0 SLOWDOWNS 2/2 ENVIRONMENTS

Coverage: 2 of 2 environments completed. Advisory result; does not block merging.

Performance diagnostics

Phase times are inclusive diagnostics and must not be added together. They identify where measured time changed, not why it changed.

No affected phases or call-count changes were recorded.

All database tasks and timings

Unix / SQL Server 2022

Database task Before After Paired change Result
Connection opening 10.312 ms 10.429 ms -0.1% no signal
SELECT queries 1.076 ms 1.084 ms +0.2% no signal
Row insertion 34.799 ms 35.124 ms +0.9% no signal
Executemany inserts 156.036 ms 157.560 ms +1.1% no signal
Fetch-all queries 121.260 ms 128.263 ms +5.8% no signal
Row-by-row fetching 14.253 ms 14.361 ms +0.8% no signal
Batched row fetching 118.834 ms 117.859 ms -0.7% no signal
Transaction commit and rollback 114.615 ms 115.162 ms +1.0% no signal
Arrow row fetching 94.592 ms 95.426 ms +1.1% no signal
100,000-row insertion 489.901 ms 451.512 ms -6.4% no signal
Row fetching in batches of 100 122.346 ms 122.527 ms -0.5% no signal
Row fetching in batches of 10,000 130.494 ms 129.030 ms +2.5% no signal
Repeated positional queries 34.112 ms 34.258 ms +1.1% no signal
Repeated named-parameter queries 36.055 ms 36.136 ms +0.4% no signal
Legacy 100,000-row insertion 371.827 ms 348.693 ms -4.9% no signal
Insertion with explicit input sizes 484.939 ms 494.286 ms +1.0% no signal
Joined aggregation queries 182.104 ms 182.338 ms +0.1% no signal
Large joined-result fetching 181.455 ms 181.631 ms -1.7% no signal
1.2-million-row fetching 3460.328 ms 3506.697 ms +1.3% no signal
Common table expression queries 5.464 ms 5.298 ms -2.7% no signal
256 KiB VARCHAR(MAX) / fetchall() 1.328 ms 1.287 ms -3.7% no signal
10,000 scalar values / fetchval() (debug disabled) 107.887 ms 106.740 ms -0.5% no signal

Unix / SQL Server 2025

Database task Before After Paired change Result
Connection opening 96.611 ms 96.761 ms +0.3% no signal
SELECT queries 1.088 ms 1.089 ms +0.4% no signal
Row insertion 34.741 ms 34.881 ms +0.5% no signal
Executemany inserts 152.166 ms 155.077 ms +1.3% no signal
Fetch-all queries 119.995 ms 121.971 ms +2.1% no signal
Row-by-row fetching 14.402 ms 14.746 ms +2.1% no signal
Batched row fetching 118.591 ms 116.872 ms -1.5% no signal
Transaction commit and rollback 123.018 ms 115.185 ms -6.4% no signal
Arrow row fetching 94.642 ms 96.523 ms +2.7% no signal
100,000-row insertion 450.177 ms 430.190 ms -4.4% no signal
Row fetching in batches of 100 121.346 ms 122.234 ms +0.1% no signal
Row fetching in batches of 10,000 133.507 ms 139.110 ms +4.2% no signal
Repeated positional queries 33.733 ms 33.529 ms -0.0% no signal
Repeated named-parameter queries 36.328 ms 36.271 ms -0.1% no signal
Legacy 100,000-row insertion 345.920 ms 346.079 ms -0.0% no signal
Insertion with explicit input sizes 541.727 ms 484.461 ms -10.6% no signal
Joined aggregation queries 161.934 ms 159.148 ms -1.2% no signal
Large joined-result fetching 183.419 ms 190.947 ms +1.5% no signal
1.2-million-row fetching 3508.325 ms 3470.779 ms -0.4% no signal
Common table expression queries 5.167 ms 5.139 ms -0.4% no signal
256 KiB VARCHAR(MAX) / fetchall() 1.448 ms 1.456 ms -1.0% no signal
10,000 scalar values / fetchval() (debug disabled) 108.382 ms 107.600 ms -1.0% no signal
Build and measurement details

ADO build 180445

PR head: d9a4515d53f1323bfd8decfb85dc63c88c579ebf
Base: 1cf04a1317b07b861f3b42f4147404006b5953ba
Measured merge: 7b405eaef822ff746873cf8eb1027ec5aaa2b122

  • Unix / SQL Server 2022: Python 3.12.3, x86_64, SQL 16.0.4295.3; 5 paired comparisons and 1 warmup.
  • Unix / SQL Server 2025: Python 3.12.3, x86_64, SQL 17.0.5005.3; 5 paired comparisons and 1 warmup.

A consistent change requires more than 20% median paired movement, at least 1 ms between the median runtimes, and at least 80% of pairs exceeding the relative threshold in the same direction. A slowdown without enough pair agreement is reported as inconsistent.

The displayed change is the median of paired before-and-after ratios. It is not recalculated from the two displayed median runtimes.

Both revisions use profiling-enabled builds on the same agent and database, with alternating order and discarded warmups. Results are diagnostic and do not represent production-wheel latency.

Raw samples and logs are attached to the ADO run as profiler-* artifacts.

@github-advanced-security github-advanced-security 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.

devskim found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@github-actions github-actions Bot added pr-size: medium Moderate update size and removed pr-size: large Substantial code update labels Sep 30, 2026

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.

Comment thread .github/workflows/lint-check.yml Outdated
Comment thread .github/workflows/lint-check.yml Outdated
Comment thread .github/workflows/lint-check.yml
Comment thread .devcontainer/post-create.sh
Copilot AI balanced review requested due to automatic review settings September 30, 2026 14:11

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.

Comment thread CONTRIBUTING.md
Copilot AI balanced review requested due to automatic review settings September 30, 2026 14:14

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.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 1, 2026 04: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.

Copilot AI balanced review requested due to automatic review settings October 1, 2026 10:02

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.

Copilot review overview

🟢 Approval recommended

The local, devcontainer, documentation, and CI formatting flows are consistently aligned with the pinned Black hook.

Review effort: Balanced
Findings: None

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 aligns local formatting with the existing CI policy without adding new blocking lint rules. approving.

@gargsaumya gargsaumya 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.

lgtm

Copilot AI balanced review requested due to automatic review settings October 5, 2026 05:37

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.

Copilot review overview

🟢 Approval recommended

The local, devcontainer, and CI formatting paths consistently use the same pinned configuration.

Review effort: Balanced
Findings: None

Copilot AI balanced review requested due to automatic review settings October 5, 2026 06:32

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.

Copilot review overview

🟡 Changes recommended

Custom core.hooksPath configurations can abort devcontainer and one-line environment setup before completion.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)

Comment thread .devcontainer/post-create.sh
Comment thread .github/prompts/setup-dev-env.prompt.md
@jahnvi480
Jahnvi Thakkar (jahnvi480) merged commit 4c4195d into main Oct 5, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-size: medium Moderate update size

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants