Skip to content

Commit e3a823a

Browse files
authored
dtype argument of read_json() (#707)
1 parent 0491c11 commit e3a823a

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

pandas-stubs/io/json/_json.pyi

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from collections import abc
2+
from collections.abc import Mapping
23
from types import TracebackType
34
from typing import (
45
Generic,
@@ -29,7 +30,7 @@ def read_json(
2930
*,
3031
orient: JsonSeriesOrient | None = ...,
3132
typ: Literal["series"],
32-
dtype: bool | dict[HashableT, DtypeArg] | None = ...,
33+
dtype: bool | Mapping[HashableT, DtypeArg] | None = ...,
3334
convert_axes: bool | None = ...,
3435
convert_dates: bool | list[str] = ...,
3536
keep_default_dates: bool = ...,
@@ -53,7 +54,7 @@ def read_json(
5354
*,
5455
orient: JsonFrameOrient | None = ...,
5556
typ: Literal["frame"] = ...,
56-
dtype: bool | dict[HashableT, DtypeArg] | None = ...,
57+
dtype: bool | Mapping[HashableT, DtypeArg] | None = ...,
5758
convert_axes: bool | None = ...,
5859
convert_dates: bool | list[str] = ...,
5960
keep_default_dates: bool = ...,
@@ -77,7 +78,7 @@ def read_json(
7778
*,
7879
orient: JsonSeriesOrient | None = ...,
7980
typ: Literal["series"],
80-
dtype: bool | dict[HashableT, DtypeArg] | None = ...,
81+
dtype: bool | Mapping[HashableT, DtypeArg] | None = ...,
8182
convert_axes: bool | None = ...,
8283
convert_dates: bool | list[str] = ...,
8384
keep_default_dates: bool = ...,
@@ -101,7 +102,7 @@ def read_json(
101102
*,
102103
orient: JsonFrameOrient | None = ...,
103104
typ: Literal["frame"] = ...,
104-
dtype: bool | dict[HashableT, DtypeArg] | None = ...,
105+
dtype: bool | Mapping[HashableT, DtypeArg] | None = ...,
105106
convert_axes: bool | None = ...,
106107
convert_dates: bool | list[str] = ...,
107108
keep_default_dates: bool = ...,

tests/test_io.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,6 +1299,9 @@ def test_all_read_without_lxml_dtype_backend() -> None:
12991299
check(
13001300
assert_type(read_json(path, dtype_backend="pyarrow"), DataFrame), DataFrame
13011301
)
1302+
check(
1303+
assert_type(read_json(path, dtype={"MatchID": str}), DataFrame), DataFrame
1304+
)
13021305

13031306
with ensure_clean() as path:
13041307
con = sqlite3.connect(path)

0 commit comments

Comments
 (0)