unionai-oss / pandera

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

check_types decorator input doesn't coerce #460

Closed jeffzi closed 3 years ago

jeffzi commented 3 years ago

Describe the bug

Related to #457, when using @check_types with a SchemaModel that has coerce=True set as the config, the input dataframe is not coerced to the specified types.

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

Code Sample, a copy-pastable example

Error comes from https://github.com/pandera-dev/pandera/blob/3191be9c1237eb07780c5c4b50c245d3a767afb3/pandera/decorators.py#L484-L488

We will need to loop over positional and keywords arguments separately to ensure we reinject the positional arguments in the correct order here https://github.com/pandera-dev/pandera/blob/3191be9c1237eb07780c5c4b50c245d3a767afb3/pandera/decorators.py#L493

Expected behavior

Functions specifying a SchemaModel input (where coerce=True) and decorated with check_types should receive a dataframe with coerced types.

jeffzi commented 3 years ago

Closed by #464