Skip to content

Commit a655347

Browse files
try fix typing
1 parent 7996aa3 commit a655347

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

pandas/io/_util.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
from __future__ import annotations
22

3-
from typing import TYPE_CHECKING
3+
from typing import (
4+
TYPE_CHECKING,
5+
Literal,
6+
)
47

58
import numpy as np
69

@@ -15,6 +18,8 @@
1518
if TYPE_CHECKING:
1619
from collections.abc import Callable
1720

21+
import pyarrow
22+
1823
from pandas._typing import DtypeBackend
1924

2025

@@ -52,8 +57,8 @@ def _arrow_string_types_mapper() -> Callable:
5257

5358

5459
def arrow_table_to_pandas(
55-
table,
56-
dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default,
60+
table: pyarrow.Table,
61+
dtype_backend: DtypeBackend | Literal["numpy"] | lib.NoDefault = lib.no_default,
5762
null_to_int64: bool = False,
5863
) -> pd.DataFrame:
5964
pa = import_optional_dependency("pyarrow")
@@ -70,7 +75,7 @@ def arrow_table_to_pandas(
7075
types_mapper = pd.ArrowDtype
7176
elif using_string_dtype():
7277
types_mapper = _arrow_string_types_mapper()
73-
elif dtype_backend is lib.no_default:
78+
elif dtype_backend is lib.no_default or dtype_backend == "numpy":
7479
types_mapper = None
7580
else:
7681
raise NotImplementedError

pandas/io/sql.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,9 +2210,6 @@ def read_table(
22102210
with self.con.cursor() as cur:
22112211
cur.execute(stmt)
22122212
pa_table = cur.fetch_arrow_table()
2213-
dtype_backend = (
2214-
lib.no_default if dtype_backend == "numpy" else dtype_backend
2215-
)
22162213
df = arrow_table_to_pandas(pa_table, dtype_backend=dtype_backend)
22172214

22182215
return _wrap_result_adbc(
@@ -2284,9 +2281,6 @@ def read_query(
22842281
with self.con.cursor() as cur:
22852282
cur.execute(sql)
22862283
pa_table = cur.fetch_arrow_table()
2287-
dtype_backend = (
2288-
lib.no_default if dtype_backend == "numpy" else dtype_backend
2289-
)
22902284
df = arrow_table_to_pandas(pa_table, dtype_backend=dtype_backend)
22912285

22922286
return _wrap_result_adbc(

0 commit comments

Comments
 (0)