Skip to content

Commit

Permalink
Remove unnecessary cast (#651)
Browse files Browse the repository at this point in the history
  • Loading branch information
sloria authored Jan 14, 2025
1 parent 14193e9 commit 9eb6127
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/marshmallow_sqlalchemy/fields.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import warnings
from typing import TYPE_CHECKING, cast
from typing import TYPE_CHECKING, Any, cast

from marshmallow import fields
from marshmallow.utils import is_iterable_but_not_string
Expand Down Expand Up @@ -52,7 +52,7 @@ def __init__(
if columns is None:
columns = column
super().__init__(**kwargs)
self.columns = cast(list[str], ensure_list(columns or []))
self.columns: list[str] = ensure_list(columns or [])

@property
def model(self) -> type[DeclarativeMeta] | None:
Expand Down Expand Up @@ -159,5 +159,5 @@ def get_primary_keys(model: type[DeclarativeMeta]) -> list[MapperProperty]:
return [mapper.get_property_by_column(column) for column in mapper.primary_key]


def ensure_list(value):
def ensure_list(value: Any) -> list:
return value if is_iterable_but_not_string(value) else [value]

0 comments on commit 9eb6127

Please sign in to comment.