-
Notifications
You must be signed in to change notification settings - Fork 25
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
__annotations__ not inherited when inheriting a model #23
Comments
I have just tried this on Patito 0.6.1 and it works fine: >>> import patito as pt
>>> class Test(pt.Model):
... col: list[str]
...
>>> class InhTest(Test):
... pass
...
>>> df = InhTest.examples({"col": [["Hello"]]})
>>> df
shape: (1, 1)
┌───────────┐
│ col │
│ --- │
│ list[str] │
╞═══════════╡
│ ["Hello"] │
└───────────┘
>>> print(Test.__annotations__)
{'col': list[str]}
>>> print(InhTest.__annotations__)
{'col': list[str]}
>>> InhTest.validate(df)
>>> df2 = InhTest.examples({"col": [["Hello", "Bye", 1]]})
>>> df2
shape: (1, 1)
┌────────────────────────┐
│ col │
│ --- │
│ list[str] │
╞════════════════════════╡
│ ["Hello", "Bye", null] │
└────────────────────────┘
>>> InhTest.validate(df2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/sam/Documents/GitHub/filebasedbim/venv/lib/python3.12/site-packages/patito/pydantic.py", line 498, in validate
validate(dataframe=dataframe, columns=columns, schema=cls, **kwargs)
File "/Users/sam/Documents/GitHub/filebasedbim/venv/lib/python3.12/site-packages/patito/validators.py", line 342, in validate
raise DataFrameValidationError(errors=errors, model=schema)
patito.exceptions.DataFrameValidationError: 1 validation error for InhTest
col
1 missing value in lists (type=value_error.missingvalues)
>>> Test.validate(df2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/sam/Documents/GitHub/filebasedbim/venv/lib/python3.12/site-packages/patito/pydantic.py", line 498, in validate
validate(dataframe=dataframe, columns=columns, schema=cls, **kwargs)
File "/Users/sam/Documents/GitHub/filebasedbim/venv/lib/python3.12/site-packages/patito/validators.py", line 342, in validate
raise DataFrameValidationError(errors=errors, model=schema)
patito.exceptions.DataFrameValidationError: 1 validation error for Test
col
1 missing value in lists (type=value_error.missingvalues)
>>> Assume that this can be closed? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is going to cause an issue when you want to validate the list column:
Reproducible example:
The text was updated successfully, but these errors were encountered: