Skip to content
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

Adding "empty" method to DataFrameSchema and SchemaModel #1039

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

a-recknagel
Copy link
Contributor

No description provided.

@a-recknagel
Copy link
Contributor Author

disabled mypy so that I could commit/push, main is broken for me right now since 5aa7795

pandera/schemas.py:801: error: Invalid index type "Tuple[Union[Series[Any], Series[bool]], List[Any]]" for "Union[_LocIndexerFrame, _LocIndexerSeries[Any]]"; expected type "Union[Series[bool], ndarray[Any, dtype[bool_]], Index, Sequence[float], List[str], slice, Tuple[Union[str, float, slice, Index], ...]]"  [index]
pandera/schemas.py:803: error: Invalid index type "Tuple[Union[Series[Any], Series[bool]], List[Any]]" for "Union[_LocIndexerFrame, _LocIndexerSeries[Any]]"; expected type "Union[Series[bool], ndarray[Any, dtype[bool_]], Index, Sequence[float], List[str], slice, Tuple[Union[str, float, slice, Index], ...]]"  [index]

Changes to the pre-commit config needs to be fixed before a merge of course.

pandera.dtypes.DataType,
pandera.engines.numpy_engine.DataType,
pandera.engines.pandas_engine.DataType,
# these fail when trying to make columns from them, but probably shouldn't
Copy link
Contributor Author

@a-recknagel a-recknagel Nov 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to remove all exceptions that aren't *.Datatype, might be tough for those where pandera.Column(...) doesn't work though -- given that that's how pandera.Column is supposed to be used.

@@ -521,6 +521,12 @@ def __modify_schema__(cls, field_schema):
"""Update pydantic field schema."""
field_schema.update(to_json_schema(cls.to_schema()))

@classmethod
@docstring_substitution(validate_doc=DataFrameSchema.empty.__doc__)
def empty(cls: Type[TSchemaModel]) -> DataFrame[TSchemaModel]:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not too sure DataFrame is the right return type here - I thought that the signature would be the same as validate, but pycharm kept complaining, and I couldn't run mypy to make sure.

@cosmicBboy
Copy link
Collaborator

@a-recknagel (btw do you have pandas-stubs installed or are the mypy errors happening without it?)

feel free to add type: ignore to mypy problem areas in the code base... it's been difficult keeping up with developments in the pandas-stubs project and ironically the pandera codebase takes some liberties with typing (mainly out of laziness). Hoping to clean that up with the internals re-write.

@a-recknagel
Copy link
Contributor Author

They are installed. Yeah, getting details with types right is a lot of work 😓

Signed-off-by: Arne Recknagel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants