FIX: Type annotation for executemany seq_of_parameters to accept Mapping#525
Open
bewithgaurav wants to merge 2 commits intomainfrom
Open
FIX: Type annotation for executemany seq_of_parameters to accept Mapping#525bewithgaurav wants to merge 2 commits intomainfrom
bewithgaurav wants to merge 2 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the Cursor.executemany type annotations/stubs to accept named-parameter batches (mappings) in addition to positional-parameter batches (sequences), aligning the public API typing with broader parameter formats (GitHub Issue #469).
Changes:
- Expanded
executemanyparameter typing to allowMapping[str, Any]batches alongsideSequence[Any]batches. - Added
Mappingimport to both runtime implementation and.pyistub to support the new type hints.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| mssql_python/mssql_python.pyi | Updates the public type stub for Cursor.executemany to accept mapping-based parameter batches. |
| mssql_python/cursor.py | Updates the runtime type annotation for Cursor.executemany to accept mapping-based parameter batches. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The type annotation for seq_of_parameters in Cursor.executemany did not accept List[Mapping[str, Any]], which is valid for pyformat-style parameters. Updated both cursor.py and mssql_python.pyi to use Union[List[Sequence[Any]], List[Mapping[str, Any]]]. Fixes #469
da087fd to
c2007c9
Compare
📊 Code Coverage Report
Diff CoverageDiff: main...HEAD, staged and unstaged changes
Summary
📋 Files Needing Attention📉 Files with overall lowest coverage (click to expand)mssql_python.pybind.logger_bridge.cpp: 59.2%
mssql_python.pybind.ddbc_bindings.h: 67.8%
mssql_python.row.py: 70.5%
mssql_python.pybind.logger_bridge.hpp: 70.8%
mssql_python.pybind.ddbc_bindings.cpp: 74.2%
mssql_python.pybind.connection.connection.cpp: 75.8%
mssql_python.__init__.py: 77.3%
mssql_python.ddbc_bindings.py: 79.6%
mssql_python.pybind.connection.connection_pool.cpp: 79.6%
mssql_python.connection.py: 85.2%🔗 Quick Links
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Work Item / Issue Reference
Summary
This pull request updates the
executemanymethod in theCursorclass to support both positional and named parameter sequences, improving compatibility with different parameter formats. The changes also update type hints and type stubs to reflect this enhancement.Type hint and API improvements:
executemanymethod incursor.pyto accept both lists of sequences (for positional parameters) and lists of mappings (for named parameters), allowing for greater flexibility in how parameters are passed.Mappingto the imports fromtypingin bothcursor.pyandmssql_python.pyito support the new type hints. [1] [2]executemanymethod inmssql_python.pyito match the new accepted parameter types, ensuring type checkers and IDEs recognize the expanded API.