unionai-oss / pandera

A light-weight, flexible, and expressive statistical data testing library
https://www.union.ai/pandera
MIT License
3.24k stars 302 forks source link

`DataFrameModel.get_metadata` should not be typed `Optional` #1750

Open adzcai opened 1 month ago

adzcai commented 1 month ago

Describe the bug pandera.api.dataframe.model.DataFrameModel.get_metadata (source) should return dict (or even a TypedDict) instead of Optional[dict] since the current implementation never returns None.

Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

import pandera as pa

class Foo(pa.DataFrameModel):
    x: int

x = Foo.get_metadata()[str(Foo)]  # Value of type "Optional[dict[Any, Any]]" is not indexable

Expected behavior

Should not return an error.

Desktop (please complete the following information):

Screenshots

N/A

Additional context

N/A

cosmicBboy commented 1 month ago

please feel free to make a PR!