Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandera/api/dataframe/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def dtypes(self) -> dict[str, DataType]:
)
return {n: c.dtype for n, c in self.columns.items() if not c.regex}

def get_metadata(self) -> dict | None:
def get_metadata(self) -> dict[Any, Any]:
"""Provide metadata for columns and schema level"""
res: dict[Any, Any] = {"columns": {}}
for k in self.columns.keys():
Expand Down
2 changes: 1 addition & 1 deletion pandera/api/dataframe/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ def _extract_df_parsers(
return [parser_info.to_parser(cls) for parser_info in parser_infos]

@classmethod
def get_metadata(cls) -> dict | None:
def get_metadata(cls) -> dict[Any, Any]:
"""Provide metadata for columns and schema level"""
res: dict[Any, Any] = {"columns": {}}
columns = cls._collect_fields()
Expand Down
15 changes: 15 additions & 0 deletions tests/mypy/pandas_modules/pandera_metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# pylint: skip-file
from typing import Any

import pandera.pandas as pa


class Foo(pa.DataFrameModel):
x: int


model_metadata: dict[Any, Any] = Foo.get_metadata()
model_value = model_metadata[str(Foo)]

schema = Foo.to_schema()
schema_metadata: dict[Any, Any] = schema.get_metadata()
2 changes: 2 additions & 0 deletions tests/mypy/test_pandas_static_type_checking.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def test_pandera_runtime_errors(fn) -> None:
["pandera_types.py", "plugin_mypy.ini", []],
["pandas_concat.py", "no_plugin.ini", []],
["pandas_concat.py", "plugin_mypy.ini", []],
["pandera_metadata.py", "no_plugin.ini", []],
["pandas_time.py", "no_plugin.ini", PANDAS_TIME_ERRORS],
["pandas_time.py", "plugin_mypy.ini", PANDAS_TIME_ERRORS],
["python_slice.py", "no_plugin.ini", PYTHON_SLICE_ERRORS],
Expand Down Expand Up @@ -292,6 +293,7 @@ def test_pandas_stubs_false_positives(
"pandera_inheritance",
"pandera_types",
"pandas_concat",
"pandera_metadata",
"pandas_time",
"python_slice",
"pandas_index",
Expand Down
Loading