diff --git a/pandas-stubs/_typing.pyi b/pandas-stubs/_typing.pyi index 6bdb6f91e..74a5a51bd 100644 --- a/pandas-stubs/_typing.pyi +++ b/pandas-stubs/_typing.pyi @@ -76,7 +76,7 @@ class FulldatetimeDict(YearMonthDayDict, total=False): # dtypes NpDtype: TypeAlias = str | np.dtype[np.generic] | type[str | complex | bool | object] Dtype: TypeAlias = ExtensionDtype | NpDtype -DtypeArg: TypeAlias = Dtype | dict[Any, Dtype] +DtypeArg: TypeAlias = Dtype | Mapping[Any, Dtype] DtypeBackend: TypeAlias = Literal["pyarrow", "numpy_nullable"] BooleanDtypeArg: TypeAlias = ( # Builtin bool type and its string alias diff --git a/tests/test_io.py b/tests/test_io.py index 99c069455..1a5b3c05a 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1388,3 +1388,23 @@ def test_read_with_lxml_dtype_backend() -> None: check( assert_type(read_xml(path, dtype_backend="pyarrow"), DataFrame), DataFrame ) + + +def test_read_sql_dict_str_value_dtype() -> None: + # GH 676 + with ensure_clean() as path: + con = sqlite3.connect(path) + check(assert_type(DF.to_sql("test", con), Union[int, None]), int) + check( + assert_type( + read_sql_query( + "select * from test", + con=con, + index_col="index", + dtype={"a": "int"}, + ), + DataFrame, + ), + DataFrame, + ) + con.close()