-
-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix to_yaml serialization dropping global checks (#428)
* increase cache version * ci: add dataframe checks tests * bugfix: allow serialization of dataframe checks to_yaml * ci: add test to ensure serialization of lambda check fails * bugfix: ensure checks with no parameters generate appropriate schema * wip: allow looking up registered checks * fix: compare checks by name rather than by object equality * ci: black * ci: lint * enh: use REGISTERED_CUSTOM_CHECKS for attribute lookup, add dir method * enh: add to_yaml method to Schema, add unit test * ci: disable typechecking on _CheckMeta * ci: isort * ci: doctests * ci: improve coverage * ci: codecov In these lines, dataframe_checks cannot be None based on the call condition. * fix unrecognized check dtype during (de)serialization * fix handle_stat__dtype closures * enh: move metaclass onto _CheckBase * ci: add test that ensures to_yaml warns on unregistered checks * ci: revert adding duplicate test Co-authored-by: cosmicBboy <[email protected]> Co-authored-by: Jean-Francois Zinque <[email protected]>
- Loading branch information
1 parent
c85ce63
commit 32543d4
Showing
13 changed files
with
358 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Pytest fixtures for testing custom checks.""" | ||
import unittest.mock as mock | ||
|
||
import pandas as pd | ||
import pytest | ||
|
||
import pandera as pa | ||
import pandera.extensions as pa_ext | ||
|
||
__all__ = "custom_check_teardown", "extra_registered_checks" | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def custom_check_teardown(): | ||
"""Remove all custom checks after execution of each pytest function.""" | ||
yield | ||
for check_name in list(pa.Check.REGISTERED_CUSTOM_CHECKS): | ||
del pa.Check.REGISTERED_CUSTOM_CHECKS[check_name] | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def extra_registered_checks(): | ||
"""temporarily registers custom checks onto the Check class""" | ||
# pylint: disable=unused-variable | ||
with mock.patch( | ||
"pandera.Check.REGISTERED_CUSTOM_CHECKS", new_callable=dict | ||
): | ||
# register custom checks here | ||
@pa_ext.register_check_method() | ||
def no_param_check(_: pd.DataFrame) -> bool: | ||
return True | ||
|
||
yield |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"""Registers fixtures for core""" | ||
|
||
# pylint: disable=unused-import | ||
from .checks_fixtures import custom_check_teardown, extra_registered_checks |
Oops, something went wrong.