Skip to content

Commit b60f9e5

Browse files
check_untyped_defs pandas.io.json._table_schema
1 parent c57ff4a commit b60f9e5

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

pandas/io/json/_table_schema.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
http://specs.frictionlessdata.io/json-table-schema/
55
"""
6+
from typing import TYPE_CHECKING, Any, Dict, Union, Optional
67
import warnings
78

89
# error: No library stub file for module 'pandas._libs.json'
@@ -24,6 +25,9 @@
2425
from pandas.api.types import CategoricalDtype
2526
import pandas.core.common as com
2627

28+
if TYPE_CHECKING:
29+
from pandas import Series # noqa: F401
30+
2731
loads = json.loads
2832

2933

@@ -190,7 +194,12 @@ def convert_json_field_to_pandas_type(field):
190194
raise ValueError("Unsupported or invalid field type: {}".format(typ))
191195

192196

193-
def build_table_schema(data, index=True, primary_key=None, version=True):
197+
def build_table_schema(
198+
data: Union["Series", DataFrame],
199+
index: bool = True,
200+
primary_key: Optional[bool] = None,
201+
version: bool = True,
202+
) -> Dict[str, Any]:
194203
"""
195204
Create a Table schema from ``data``.
196205
@@ -239,7 +248,7 @@ def build_table_schema(data, index=True, primary_key=None, version=True):
239248
if index is True:
240249
data = set_default_names(data)
241250

242-
schema = {}
251+
schema: Dict[str, Any] = {}
243252
fields = []
244253

245254
if index:

setup.cfg

-3
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,6 @@ check_untyped_defs=False
291291
[mypy-pandas.io.json._normalize]
292292
check_untyped_defs=False
293293

294-
[mypy-pandas.io.json._table_schema]
295-
check_untyped_defs=False
296-
297294
[mypy-pandas.io.packers]
298295
check_untyped_defs=False
299296

0 commit comments

Comments
 (0)