-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor expectation registration #12
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
Conversation
…afe enums for categories
…ctation functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the expectation registration system to use Pydantic for metadata validation and introduces automatic stub file generation for IDE autocomplete support. The main changes include:
- Addition of Pydantic dependency for metadata validation
- Dynamic method generation in
DataFrameExpectationsSuiteusing__getattr__ - Automatic
.pyistub file generation for IDE support - Enhanced expectation registry with metadata tracking using enums and Pydantic models
Reviewed Changes
Copilot reviewed 19 out of 20 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Adds pydantic 2.12.4 and dependencies (annotated-types, pydantic-core, typing-inspection) |
| pyproject.toml | Adds pydantic>=2.12.4 dependency |
| dataframe_expectations/expectations/expectation_registry.py | Adds ExpectationMetadata model, enums for categories, and metadata tracking |
| dataframe_expectations/expectations_suite.py | Refactors to use dynamic method generation via getattr |
| scripts/generate_suite_stubs.py | New script to generate .pyi stub files from registry metadata |
| dataframe_expectations/expectations_suite.pyi | Auto-generated type stubs for IDE autocomplete |
| scripts/sanity_checks.py | Updates to validate stub file and use registry for suite methods |
| tests/expectations_helper_classes/test_expectation_registry.py | Updates test registrations with new required metadata parameters |
| docs/source/adding_expectations.rst | Updated documentation for new registration API |
| .pre-commit-config.yaml | Adds check for stub file freshness |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
This PR refactors the expectation registration system to address the growing size of the
DataFrameExpectationsSuiteclass (previously 800+ lines of boilerplate). The new architecture replaces manual method definitions with dynamic generation from a central registry, while maintaining full IDE type-ahead support through auto-generated stub files.Key Changes:
generate_suite_stubs.pyfrom registry metadataAll
@register_expectationdecorators now require complete metadata:Checklist