Commit 3670cf8
Add Polars pydantic integration with format support and native JSON schema generation (#1979)
* Add Polars pydantic integration with format support and native JSON schema generation
- Add pydantic validation for Polars DataFrames and LazyFrames
- Implement DataFrame type conversion from various formats (dict, CSV, JSON, Parquet, Feather)
- Replace pandas dependency with native Polars JSON schema generation
- Support both Pydantic v1 and v2 with appropriate validators
- Add comprehensive test suite for the integration
Signed-off-by: Arkadiusz Halicki <[email protected]>
* Blacken the code
Signed-off-by: Arkadiusz Halicki <[email protected]>
* fix pylint issues
Signed-off-by: cosmicBboy <[email protected]>
* Add comprehensive test coverage for typing/polars.py
- Add new test file test_polars_typing.py with complete coverage for polars typing module
- Test DataFrame.from_format and to_format with various data formats
- Cover both success and error paths
- Add tests for Pydantic integration
- Add pragmas to conditionally exclude import-time and version-specific code from coverage
Achieves 100% test coverage for the module.
Signed-off-by: Arkadiusz Halicki <[email protected]>
* Remove pragma no cover directives from typing/polars.py
Tests now provide sufficient coverage without the need for pragma directives.
Signed-off-by: Arkadiusz Halicki <[email protected]>
* Add test coverage for typing/polars.py with pragmas
- Created comprehensive test suite for typing/polars.py
- Added tests for DataFrame, LazyFrame, and Series classes
- Added tests for format conversion methods
- Added tests for Pydantic integration (v1 and v2)
- Added pragma no cover to hard-to-test code paths
- Achieved 100% test coverage
Signed-off-by: Arkadiusz Halicki <[email protected]>
* Blacken the code again
Signed-off-by: Arkadiusz Halicki <[email protected]>
* Cleanup
Signed-off-by: Arkadiusz Halicki <[email protected]>
* test(polars): Add tests for optional columns in Polars DataFrameModel
This commit adds test cases that demonstrate how to use optional columns
with Polars DataFrameModels when integrating with Pydantic. The tests show:
- Using Optional[Series[type]] annotation to make a column optional
- Validating DataFrames with and without the optional column
- Ensuring type validation still works on optional columns when present
- Verifying that required columns still must be present
These tests help document the supported patterns for optional columns
in Pandera's Polars integration.
Signed-off-by: Arkadiusz Halicki <[email protected]>
* Blacken the code
Signed-off-by: Arkadiusz Halicki <[email protected]>
* Import specific pandera impl
Signed-off-by: Arkadiusz Halicki <[email protected]>
---------
Signed-off-by: Arkadiusz Halicki <[email protected]>
Signed-off-by: cosmicBboy <[email protected]>
Co-authored-by: cosmicBboy <[email protected]>1 parent 88bb609 commit 3670cf8
File tree
4 files changed
+1633
-21
lines changed- pandera
- api/polars
- typing
- tests/polars
4 files changed
+1633
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
173 | | - | |
174 | 172 | | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | 173 | | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | 174 | | |
188 | | - | |
189 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
190 | 233 | | |
191 | | - | |
| 234 | + | |
192 | 235 | | |
193 | 236 | | |
194 | 237 | | |
195 | 238 | | |
196 | 239 | | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
| 240 | + | |
201 | 241 | | |
202 | 242 | | |
203 | 243 | | |
| |||
0 commit comments