Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #294 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 54 55 +1
Lines 3121 3250 +129
==========================================
+ Hits 3121 3250 +129 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds a new dy.infer_schema() function (addressing Issue #232) that generates dataframely schema code from a Polars DataFrame. The function inspects a DataFrame's column types and null counts to produce schema class definitions with appropriate column types and nullable annotations.
Changes:
- New
dataframely/_generate_schema.pymodule implementinginfer_schema()with three return modes (print to stdout, return as string, or return as an executable Schema class), plus supporting helper functions for code generation. - Public API export of
infer_schemaindataframely/__init__.py. - New test file
tests/test_infer_schema.pycovering basic types, nullable detection, datetime types, nested types, invalid identifiers, and round-trip validation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
dataframely/_generate_schema.py |
New module with infer_schema() function and helpers for inferring schema from DataFrame columns, handling type mapping, identifier sanitization, and code generation. |
dataframely/__init__.py |
Exports infer_schema in the public API (import and __all__). |
tests/test_infer_schema.py |
Tests for string output mode across all supported types and round-trip validation via schema return mode. |
added 2 commits
March 5, 2026 11:20
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #232
dy.infer_schema()function to generate dataframely schema code from a Polars DataFramereturn_typeparameter:None(default): prints schema to stdout for quick exploration"string": returns schema code as a string"schema": returns an actual Schema class for direct useThis add the
Not supported (potential future enhancements)