Skip to content

Commit

Permalink
try fix typing
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisvandenbossche committed Nov 15, 2024
1 parent 7996aa3 commit a655347
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
13 changes: 9 additions & 4 deletions pandas/io/_util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import (
TYPE_CHECKING,
Literal,
)

import numpy as np

Expand All @@ -15,6 +18,8 @@
if TYPE_CHECKING:
from collections.abc import Callable

import pyarrow

from pandas._typing import DtypeBackend


Expand Down Expand Up @@ -52,8 +57,8 @@ def _arrow_string_types_mapper() -> Callable:


def arrow_table_to_pandas(
table,
dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default,
table: pyarrow.Table,
dtype_backend: DtypeBackend | Literal["numpy"] | lib.NoDefault = lib.no_default,
null_to_int64: bool = False,
) -> pd.DataFrame:
pa = import_optional_dependency("pyarrow")
Expand All @@ -70,7 +75,7 @@ def arrow_table_to_pandas(
types_mapper = pd.ArrowDtype
elif using_string_dtype():
types_mapper = _arrow_string_types_mapper()
elif dtype_backend is lib.no_default:
elif dtype_backend is lib.no_default or dtype_backend == "numpy":
types_mapper = None
else:
raise NotImplementedError
Expand Down
6 changes: 0 additions & 6 deletions pandas/io/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -2210,9 +2210,6 @@ def read_table(
with self.con.cursor() as cur:
cur.execute(stmt)
pa_table = cur.fetch_arrow_table()
dtype_backend = (
lib.no_default if dtype_backend == "numpy" else dtype_backend
)
df = arrow_table_to_pandas(pa_table, dtype_backend=dtype_backend)

return _wrap_result_adbc(
Expand Down Expand Up @@ -2284,9 +2281,6 @@ def read_query(
with self.con.cursor() as cur:
cur.execute(sql)
pa_table = cur.fetch_arrow_table()
dtype_backend = (
lib.no_default if dtype_backend == "numpy" else dtype_backend
)
df = arrow_table_to_pandas(pa_table, dtype_backend=dtype_backend)

return _wrap_result_adbc(
Expand Down

0 comments on commit a655347

Please sign in to comment.