-
-
Notifications
You must be signed in to change notification settings - Fork 308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Dict, List generic types when using check_types for runtime validation #1078
Comments
hi @nolanbconaway, Would need to add support for this use case as well. Re-labelling this as an enhancement. The bug is perhaps that |
Ah that makes sense! Thanks for the fast response |
Would welcome a community contribution for this! Will need to extend this to pulling out a |
Hey! I gave this a couple hours and I think it goes a bit deeper than I have space to look. The Union type is a generalization of the current functionality in that the argument value is still a single dataframe. With dicts, lists, etc; pandera would need to support arbitrarily nested type hints. With that comes the possibility that multiple dataframes are provided for a single argument, and those could have different schemas. e.g., def f() -> Tuple[DataFrame[s1], DataFrame[s2]]:
... The decorator runs off of From what I can tell, some form of zipping the arguments to the annotation would be needed to handle this sanely, but that feels like a bigger architectural change than i have time to support. I added a pr with as far as i got, in case someone with more knowledge/time thinks this is worth pursuing! #1084 |
thanks @nolanbconaway! yeah won't have capacity to work on this any time soon, but I'm adding a |
Describe the bug
I have a function which I am checking with
pa.check_types
. The output type is not only a dataframe schema, but has these types nested, likeDict[str, pa.typing.DataFrame[Schema]]
.SchemaError
is not raised when the return type is invalid in this case; it is only raised when the schema is the return type of the function.Are these kinds of signatures supported by pandera? Is there a supported approach to this kind of thing?
Code Sample, a copy-pastable example
Expected behavior
I was expecting schema error to be raised in both cases.
Desktop (please complete the following information):
Screenshots
Additional context
The text was updated successfully, but these errors were encountered: