pandera icon indicating copy to clipboard operation
pandera copied to clipboard

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

Open adzcai opened this issue 1 year ago • 1 comments
trafficstars

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.

  • [x] I have checked that this issue has not already been reported.
  • [x] I have confirmed this bug exists on the latest version of pandera.
  • [x] (optional) I have confirmed this bug exists on the main branch of pandera.

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):

  • OS: macOS 14.4
  • Browser: N/A
  • Version: 0.20.2

Screenshots

N/A

Additional context

N/A

adzcai avatar Jul 18 '24 12:07 adzcai

please feel free to make a PR!

cosmicBboy avatar Jul 18 '24 12:07 cosmicBboy