Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mssql_python/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import uuid
import datetime
import warnings
from typing import List, Union, Any, Optional, Tuple, Sequence, TYPE_CHECKING, Iterable
from typing import List, Mapping, Union, Any, Optional, Tuple, Sequence, TYPE_CHECKING, Iterable
from mssql_python.constants import ConstantsDDBC as ddbc_sql_const, SQLTypes
from mssql_python.helpers import check_error, connstr_to_pycore_params
from mssql_python.logging import logger
Expand Down Expand Up @@ -2063,7 +2063,7 @@ def _compute_column_type(self, column):
return sample_value, None, None

def executemany( # pylint: disable=too-many-locals,too-many-branches,too-many-statements
self, operation: str, seq_of_parameters: List[Sequence[Any]]
self, operation: str, seq_of_parameters: Union[List[Sequence[Any]], List[Mapping[str, Any]]]
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

The seq_of_parameters annotation is unnecessarily restrictive by requiring a List[...]. In practice (and per common DB-API usage), callers often pass tuples/other iterables. Consider widening the annotation to Sequence[...] or Iterable[...] (e.g., Iterable[Sequence[Any]] | Iterable[Mapping[str, Any]], or Iterable[Sequence[Any] | Mapping[str, Any]] if mixed batches are supported) so type checking matches the accepted runtime inputs.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

The expanded executemany type is getting harder to read and now must be duplicated in both cursor.py and mssql_python.pyi. To reduce repetition and make future changes less error-prone, consider introducing a well-named type alias (e.g., ExecutemanyParams) and using it in the signature (and in the stub if feasible).

Copilot uses AI. Check for mistakes.
) -> None:
"""
Prepare a database operation and execute it against all parameter sequences.
Expand Down
4 changes: 2 additions & 2 deletions mssql_python/mssql_python.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Licensed under the MIT license.
Type stubs for mssql_python package - based on actual public API
"""

from typing import Any, Dict, List, Optional, Union, Tuple, Sequence, Callable, Iterator
from typing import Any, Dict, List, Mapping, Optional, Union, Tuple, Sequence, Callable, Iterator
import datetime
import logging
import pyarrow
Expand Down Expand Up @@ -192,7 +192,7 @@ class Cursor:
use_prepare: bool = True,
reset_cursor: bool = True,
) -> "Cursor": ...
def executemany(self, operation: str, seq_of_parameters: List[Sequence[Any]]) -> None: ...
def executemany(self, operation: str, seq_of_parameters: Union[List[Sequence[Any]], List[Mapping[str, Any]]]) -> None: ...
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

Same as the runtime annotation: the stub currently forces List[...], which rejects valid inputs like tuples or other sequence/iterable types in type checkers. Please widen the stub to Sequence[...] or Iterable[...] to reflect typical executemany usage and keep typing ergonomic for callers.

Copilot uses AI. Check for mistakes.
def fetchone(self) -> Optional[Row]: ...
def fetchmany(self, size: Optional[int] = None) -> List[Row]: ...
def fetchall(self) -> List[Row]: ...
Expand Down
Loading