Skip to content

Commit

Permalink
fix: prefer sqlalchemy.type.impl if it exists (#502)
Browse files Browse the repository at this point in the history
  • Loading branch information
cofin authored Feb 17, 2024
1 parent 1ae2d52 commit c4e3d91
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion polyfactory/factories/sqlalchemy_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ def get_type_from_column(cls, column: Column) -> type:
elif issubclass(column_type, types.ARRAY):
annotation = List[column.type.item_type.python_type] # type: ignore[assignment,name-defined]
else:
annotation = column.type.python_type
annotation = (
column.type.impl.python_type # pyright: ignore[reportGeneralTypeIssues]
if hasattr(column.type, "impl")
else column.type.python_type
)

if column.nullable:
annotation = Union[annotation, None] # type: ignore[assignment]
Expand Down

0 comments on commit c4e3d91

Please sign in to comment.