patito 0.8.3__py3-none-any.whl → 0.8.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
patito/_pydantic/repr.py CHANGED
@@ -90,7 +90,7 @@ class Representation:
90
90
  return self.__repr_str__(" ")
91
91
 
92
92
  def __repr__(self) -> str:
93
- return f'{self.__repr_name__()}({self.__repr_str__(", ")})'
93
+ return f"{self.__repr_name__()}({self.__repr_str__(', ')})"
94
94
 
95
95
  def __rich_repr__(self) -> "RichReprResult":
96
96
  """Get fields for Rich library."""
patito/exceptions.py CHANGED
@@ -79,7 +79,7 @@ class DataFrameValidationError(Representation, ValueError):
79
79
  errors = self.errors()
80
80
  no_errors = len(errors)
81
81
  return (
82
- f'{no_errors} validation error{"" if no_errors == 1 else "s"} for {self.model.__name__}\n'
82
+ f"{no_errors} validation error{'' if no_errors == 1 else 's'} for {self.model.__name__}\n"
83
83
  f"{display_errors(errors)}"
84
84
  )
85
85
 
@@ -90,7 +90,7 @@ class DataFrameValidationError(Representation, ValueError):
90
90
 
91
91
  def display_errors(errors: list["ErrorDict"]) -> str:
92
92
  return "\n".join(
93
- f'{_display_error_loc(e)}\n {e["msg"]} ({_display_error_type_and_ctx(e)})'
93
+ f"{_display_error_loc(e)}\n {e['msg']} ({_display_error_type_and_ctx(e)})"
94
94
  for e in errors
95
95
  )
96
96
 
patito/polars.py CHANGED
@@ -213,7 +213,7 @@ class LazyFrame(pl.LazyFrame, Generic[ModelType]):
213
213
  lf = lf.with_columns(derived_from.cast(dtype).alias(column_name))
214
214
  else:
215
215
  raise TypeError(
216
- "Can not derive dataframe column from type " f"{type(derived_from)}."
216
+ f"Can not derive dataframe column from type {type(derived_from)}."
217
217
  )
218
218
  derived_columns.append(column_name)
219
219
  return lf, derived_columns
@@ -337,7 +337,7 @@ class LazyFrame(pl.LazyFrame, Generic[ModelType]):
337
337
  def from_existing(cls: type[LDF], lf: pl.LazyFrame) -> LDF:
338
338
  """Construct a patito.DataFrame object from an existing polars.DataFrame object."""
339
339
  if getattr(cls, "model", False):
340
- return cls.model.LazyFrame._from_pyldf(super().lazy()._ldf) # type: ignore
340
+ return cls.model.LazyFrame._from_pyldf(super().lazy(lf)._ldf) # type: ignore
341
341
 
342
342
  return LazyFrame._from_pyldf(lf._ldf) # type: ignore
343
343
 
patito/validators.py CHANGED
@@ -68,9 +68,9 @@ def _transform_df(dataframe: pl.DataFrame, schema: type[Model]) -> pl.DataFrame:
68
68
  if alias_gen := schema.model_config.get("alias_generator"):
69
69
  if isinstance(alias_gen, AliasGenerator):
70
70
  alias_func = alias_gen.validation_alias or alias_gen.alias
71
- assert (
72
- alias_func is not None
73
- ), "An AliasGenerator must contain a transforming function"
71
+ assert alias_func is not None, (
72
+ "An AliasGenerator must contain a transforming function"
73
+ )
74
74
  else: # alias_gen is a function
75
75
  alias_func = alias_gen
76
76
 
@@ -129,7 +129,7 @@ def _find_errors( # noqa: C901
129
129
  )
130
130
  )
131
131
 
132
- if not allow_superfluous_columns:
132
+ if not (allow_superfluous_columns or schema.model_config.get("extra") == "allow"):
133
133
  # Check if any additional columns are included
134
134
  for superfluous_column in set(column_subset) - set(schema.columns):
135
135
  errors.append(
@@ -1,35 +1,22 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: patito
3
- Version: 0.8.3
3
+ Version: 0.8.4
4
4
  Summary: A dataframe modelling library built on top of polars and pydantic.
5
- Home-page: https://github.com/JakobGM/patito
6
- License: MIT
7
- Keywords: validation,dataframe
8
- Author: Jakob Gerhard Martinussen
9
- Author-email: jakobgm@gmail.com
5
+ Project-URL: Homepage, https://github.com/JakobGM/patito
6
+ Project-URL: Repository, https://github.com/JakobGM/patito
7
+ Project-URL: Documentation, https://patito.readthedocs.io
8
+ Author-email: Jakob Gerhard Martinussen <jakobgm@gmail.com>, Thomas Aarholt <thomasaarholt@gmail.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: dataframe,validation
10
12
  Requires-Python: >=3.9
11
- Classifier: License :: OSI Approved :: MIT License
12
- Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.9
14
- Classifier: Programming Language :: Python :: 3.10
15
- Classifier: Programming Language :: Python :: 3.11
16
- Classifier: Programming Language :: Python :: 3.12
13
+ Requires-Dist: polars>=1.10.0
14
+ Requires-Dist: pydantic>=2.7.0
15
+ Requires-Dist: typing-extensions
17
16
  Provides-Extra: caching
18
- Provides-Extra: docs
17
+ Requires-Dist: pyarrow>=5.0.0; extra == 'caching'
19
18
  Provides-Extra: pandas
20
- Requires-Dist: Sphinx (<7) ; extra == "docs"
21
- Requires-Dist: pandas ; extra == "pandas"
22
- Requires-Dist: polars (>=1.10.0)
23
- Requires-Dist: pyarrow (>=5.0.0) ; extra == "caching"
24
- Requires-Dist: pydantic (>=2.7.0)
25
- Requires-Dist: sphinx-autobuild ; extra == "docs"
26
- Requires-Dist: sphinx-autodoc-typehints ; extra == "docs"
27
- Requires-Dist: sphinx-rtd-theme ; extra == "docs"
28
- Requires-Dist: sphinx-toolbox ; extra == "docs"
29
- Requires-Dist: sphinxcontrib-mermaid ; extra == "docs"
30
- Requires-Dist: typing-extensions
31
- Project-URL: Documentation, https://patito.readthedocs.io
32
- Project-URL: Repository, https://github.com/JakobGM/patito
19
+ Requires-Dist: pandas; extra == 'pandas'
33
20
  Description-Content-Type: text/markdown
34
21
 
35
22
  # <center><img height="30px" src="https://em-content.zobj.net/thumbs/120/samsung/78/duck_1f986.png"> Patito<center>
@@ -307,4 +294,3 @@ milk = products.get(pl.col("product_id") == 1)
307
294
  print(milk.url)
308
295
  # https://example.com/no/products/1-skimmed-milk
309
296
  ```
310
-
@@ -1,17 +1,17 @@
1
1
  patito/__init__.py,sha256=4qD13kfoa85_kyTCChm3xQcKKzIy3G8AZQp8T_bjcmo,844
2
2
  patito/_docs.py,sha256=9mfttyylWpqaOZv8xfDMEwCHHaY7GQwfyI7CDg7tWe8,162
3
+ patito/exceptions.py,sha256=rv0AUVqxxnP00wmjgaqOPz0Ht6er-SjdeunHAul9brs,6034
4
+ patito/polars.py,sha256=yZjT-7GoZnh26vf8jbagOnSV3Zjy89Diyr3E3LYoqJI,38789
5
+ patito/pydantic.py,sha256=yrpbjjqu8fRJkoPWt_uCAfs2yNDDBB1OviZwxnnPKpI,49456
6
+ patito/validators.py,sha256=Ne6mj8js3RDAcgw6p558wdic3VA7Kbu6AgDIq0X9hzg,18603
3
7
  patito/_pydantic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
8
  patito/_pydantic/column_info.py,sha256=u6sZ2212VppgBmcISWzGNY6ZfBiNFJtlwj1lDXDFL4c,5366
9
+ patito/_pydantic/repr.py,sha256=qMQwkEzfr9t4aIo1O2IxHC5r2QreuxYNQKT5eddkDQs,4182
10
+ patito/_pydantic/schema.py,sha256=BI2qAhNM29NxS366K9eRi8thgE2P3t8GFt1HzwlWxos,3603
5
11
  patito/_pydantic/dtypes/__init__.py,sha256=2vTvL4N4yMN0cbv2CSoa1OFwCswx6FhuQdsYhMaz_dU,578
6
12
  patito/_pydantic/dtypes/dtypes.py,sha256=KETa3U01sQEub6sCckCHfNz781LOlvziRwxADkyUQyA,9842
7
13
  patito/_pydantic/dtypes/utils.py,sha256=wuJv-cYDftaN1OLCGM4sPlEMsIj7rZLlaHKezBa474U,6659
8
- patito/_pydantic/repr.py,sha256=P7ojqTeNM4htzZgw2qMO6XzFqkiIXLwP-WUIEqNt7I0,4182
9
- patito/_pydantic/schema.py,sha256=BI2qAhNM29NxS366K9eRi8thgE2P3t8GFt1HzwlWxos,3603
10
- patito/exceptions.py,sha256=XK6UF_UojeOR45TJnZqS19SHZAUIvu-nswqf1tnFJ08,6034
11
- patito/polars.py,sha256=Zqk6m26EjRQwp6Ug0UALyYDNT9cbz-GyqZ8_uLWuFwU,38790
12
- patito/pydantic.py,sha256=yrpbjjqu8fRJkoPWt_uCAfs2yNDDBB1OviZwxnnPKpI,49456
13
- patito/validators.py,sha256=g6zAzV-C50ffkNkHV1FzGzJKeaBzs09DK2liXsnHphI,18554
14
- patito-0.8.3.dist-info/LICENSE,sha256=3bc4YyuF0e5nd59E3CsR8QM1Ua7pqKfC9DD1LVBVMs4,1139
15
- patito-0.8.3.dist-info/METADATA,sha256=G_MOL6X9cvOZrvjxvqS4-Eo-xYjO0jG5kw61c4cgMOs,13999
16
- patito-0.8.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
17
- patito-0.8.3.dist-info/RECORD,,
14
+ patito-0.8.4.dist-info/METADATA,sha256=v5d1asFZgurphx8ysZxsM3PM_B-iC1SkZQlOeiccUMk,13439
15
+ patito-0.8.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ patito-0.8.4.dist-info/licenses/LICENSE,sha256=3bc4YyuF0e5nd59E3CsR8QM1Ua7pqKfC9DD1LVBVMs4,1139
17
+ patito-0.8.4.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.0
2
+ Generator: hatchling 1.27.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any