Skip to content

Commit

Permalink
Fix two type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasaarholt committed Nov 1, 2023
1 parent e62fbf1 commit e9eb2c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/patito/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class ValidationError(ValueError):
"""Exception raised when dataframe does not match schema."""

def __init__(self, errors: Sequence["ErrorWrapper"], model: Model) -> None:
def __init__(self, errors: Sequence["ErrorWrapper"], model: type[Model]) -> None:
self.raw_errors = errors
self.model = model

Expand Down
5 changes: 5 additions & 0 deletions src/patito/pydantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,11 @@ def join(
):
for field_name, field in model.model_fields.items():
field_annotation = field.annotation
# Fix type error that field_annotation has type `type | None`,
# we want field_annotation as either `type` or `type | Type[None]`,
# where the latter means nullable
assert field_annotation is not None, "Column type cannot be null!"

if how in nullable_methods and type(None) not in get_args(
field_annotation
):
Expand Down

0 comments on commit e9eb2c7

Please sign in to comment.