Skip to content

CHORE: Gate PRs on strict mssql_python typing - #827

Draft
Jahnvi Thakkar (jahnvi480) wants to merge 1 commit into
mainfrom
jahnvi/fluffy-adventure
Draft

Jahnvi Thakkar (jahnvi480) wants to merge 1 commit into
mainfrom
jahnvi/fluffy-adventure

Conversation

@jahnvi480

@jahnvi480 Jahnvi Thakkar (jahnvi480) commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Work Item / Issue Reference

AB#45120


Summary

Add a blocking strict-mypy check to the existing Ubuntu PR-validation
job, targeting only Python source and stubs under mssql_python.
Exclude tests and mssql_python_odbc from this typing gate while
preserving existing runtime test jobs.

Resolve driver typing diagnostics, add native-interface declarations,
and align public stubs, packaging, documentation, and regression coverage.

Draft follow-up: refresh the Linux dependency lockfile; the current
attempt is blocked by PyPI TLS connection failures.

AB#45120

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 30, 2026 12:13
@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.040 ms 10.140 ms +1.0% no signal
SELECT queries 1.060 ms 1.052 ms -0.7% no signal
Row insertion 34.013 ms 33.644 ms -0.7% no signal
Executemany inserts 156.296 ms 156.123 ms -0.0% no signal
Fetch-all queries 120.075 ms 120.036 ms -0.3% no signal
Row-by-row fetching 14.352 ms 14.445 ms +0.7% no signal
Batched row fetching 116.722 ms 117.581 ms -0.8% no signal
Transaction commit and rollback 113.369 ms 111.969 ms -1.4% no signal
Arrow row fetching 152.859 ms 155.286 ms +1.6% no signal
100,000-row insertion 447.438 ms 451.781 ms +0.9% no signal
Row fetching in batches of 100 121.918 ms 122.506 ms +0.5% no signal
Row fetching in batches of 10,000 140.176 ms 138.578 ms +1.3% no signal
Repeated positional queries 33.416 ms 33.101 ms -0.9% no signal
Repeated named-parameter queries 35.877 ms 35.589 ms -1.5% no signal
Legacy 100,000-row insertion 352.171 ms 350.582 ms -0.8% no signal
Insertion with explicit input sizes 488.911 ms 499.333 ms +0.5% no signal
Joined aggregation queries 176.572 ms 175.307 ms -0.7% no signal
Large joined-result fetching 196.951 ms 177.200 ms -8.9% no signal
1.2-million-row fetching 3469.093 ms 3483.921 ms +0.4% no signal
Common table expression queries 5.238 ms 5.230 ms -0.1% no signal
256 KiB VARCHAR(MAX) / fetchall() 1.378 ms 1.289 ms -5.1% no signal

Unix / SQL Server 2025

Database task Before After Paired change Result
Connection opening 97.225 ms 97.685 ms +0.7% no signal
SELECT queries 1.153 ms 1.185 ms +2.3% no signal
Row insertion 35.195 ms 35.308 ms +0.3% no signal
Executemany inserts 152.062 ms 152.013 ms +0.7% no signal
Fetch-all queries 126.234 ms 125.383 ms +0.3% no signal
Row-by-row fetching 14.397 ms 14.440 ms +0.5% no signal
Batched row fetching 120.015 ms 122.138 ms +1.4% no signal
Transaction commit and rollback 117.763 ms 118.139 ms +0.6% no signal
Arrow row fetching 156.877 ms 159.498 ms +1.5% no signal
100,000-row insertion 473.619 ms 452.941 ms +1.0% no signal
Row fetching in batches of 100 123.847 ms 124.327 ms +0.5% no signal
Row fetching in batches of 10,000 150.837 ms 151.293 ms -0.0% no signal
Repeated positional queries 34.370 ms 34.253 ms -1.8% no signal
Repeated named-parameter queries 36.625 ms 36.566 ms -0.4% no signal
Legacy 100,000-row insertion 369.366 ms 380.216 ms -1.4% no signal
Insertion with explicit input sizes 516.672 ms 512.913 ms +0.3% no signal
Joined aggregation queries 159.913 ms 159.048 ms -0.3% no signal
Large joined-result fetching 189.041 ms 189.125 ms +0.0% no signal
1.2-million-row fetching 3627.372 ms 3567.066 ms -0.4% no signal
Common table expression queries 5.320 ms 5.352 ms +0.2% no signal
256 KiB VARCHAR(MAX) / fetchall() 1.598 ms 1.543 ms -2.1% no signal
Build and measurement details

ADO build 179380

PR head: 203eb0d96bd87180c2e0d32a987d2e2c10d6e035
Base: fead15c30e49172bab643bc9cc5504936e86459e
Measured merge: fcd8dc75eb1df69778663156a99a8065f96499e3

  • 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-actions

Copy link
Copy Markdown

📊 Code Coverage Report

🔥 Diff Coverage

100%


🎯 Overall Coverage

84%


📈 Total Lines Covered: 9443 out of 11126
📁 Project: mssql-python


Diff Coverage

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

  • mssql_python/init.py (100%)
  • mssql_python/async_query/init.py (100%)
  • mssql_python/async_query/_native.py (100%)
  • mssql_python/async_query/async_connection.py (100%)
  • mssql_python/async_query/async_cursor.py (100%)
  • mssql_python/async_query/async_fetch.py (100%)
  • mssql_python/async_query/exception_translator.py (100%)
  • mssql_python/auth.py (100%)
  • mssql_python/connection.py (100%)
  • mssql_python/constants.py (100%)
  • mssql_python/cursor.py (100%)
  • mssql_python/db_connection.py (100%)
  • mssql_python/ddbc_bindings.py (100%)
  • mssql_python/decimal_config.py (100%)
  • mssql_python/exceptions.py (100%)
  • mssql_python/helpers.py (100%)
  • mssql_python/logging.py (100%)
  • mssql_python/parameter_helper.py (100%)
  • mssql_python/perf_timer.py (100%)
  • mssql_python/pooling.py (100%)
  • mssql_python/row.py (100%)
  • mssql_python/type.py (100%)

Summary

  • Total: 291 lines
  • Missing: 0 lines
  • Coverage: 100%

📋 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.ddbc_bindings.cpp: 79.3%
mssql_python.pybind.connection.connection_pool.cpp: 82.3%
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%

🔗 Quick Links

⚙️ Build Summary 📋 Coverage Details

View Azure DevOps Build

Browse Full Coverage Report

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

Decimal column inference still accepts singleton and mixed-type non-finite values.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

This PR adds a blocking strict-typing gate for mssql_python to PR validation and aligns the driver’s type declarations with its Python and native interfaces.

Changes:

  • Add a package-scoped mypy harness and run it in the Ubuntu PR-validation job.
  • Add native-interface stubs, source annotations, and targeted regression tests.
  • Update packaging and contributor guidance for the typing gate.
File Description
tests/​test_typing.py Adds the strict-typing harness.
tests/​test_005_connection_cursor_lifecycle.py Tests closed-connection guards.
tests/​test_004_cursor.py Adds Decimal and row regression checks.
tests/​test_004_cursor_arrow.py Tests Arrow reader cleanup.
tests/​test_000_dependencies.py Checks declaration and runtime exports.
setup.py Packages stub files.
requirements.txt Adds pinned mypy and typing stubs.
pytest.ini Separates typing checks from default tests.
mssql_python/​type.py Annotates DB-API type objects.
mssql_python/​row.py Annotates rows and mapping access.
mssql_python/​pooling.py Annotates pooling shutdown.
mssql_python/​perf_timer.py Types profiler results and methods.
mssql_python/​parameter_helper.py Types parameter conversion.
mssql_python/​mssql_python.pyi Aligns public API declarations.
mssql_python/​logging.py Annotates logging APIs.
mssql_python/​helpers.py Types connection-string translation.
mssql_python/​exceptions.py Types exception reconstruction.
mssql_python/​decimal_config.py Types decimal-setting callbacks.
mssql_python/​ddbc_bindings.py Types the native loader boundary.
mssql_python/​db_connection.py Clarifies the connection re-export.
mssql_python/​cursor.py Annotates cursor paths and adds guards.
mssql_python/​constants.py Declares dynamic constant types.
mssql_python/​connection.py Annotates connection state and guards.
mssql_python/​auth.py Types credential and token handling.
mssql_python/​async_query/​exception_translator.py Types exception classification.
mssql_python/​async_query/​async_fetch.py Types the native cursor accessor.
mssql_python/​async_query/​async_cursor.py Types the async cursor wrapper.
mssql_python/​async_query/​async_connection.py Types the async connection wrapper.
mssql_python/​async_query/​_native.py Types native-core loading.
mssql_python/​async_query/​__init__.py Clarifies async re-exports.
mssql_python/​_pycore_types.pyi Declares Rust-core interfaces.
mssql_python/​_ddbc_types.pyi Declares C++ binding interfaces.
mssql_python/​__init__.py Annotates package helpers.
eng/​pipelines/​pr-validation-pipeline.yml Adds the blocking typing job step.
CONTRIBUTING.md Documents the typing workflow.
.github/​prompts/​run-tests.prompt.md Documents how to run typing checks.
.github/​copilot-instructions.md Updates validation guidance.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread mssql_python/cursor.py
return columnwise, row_count

def _compute_column_type(self, column):
def _compute_column_type(
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.

2 participants