Skip to content

Commit

Permalink
fix: 🚨 fix mypy typing
Browse files Browse the repository at this point in the history
  • Loading branch information
dubusster committed Mar 29, 2024
1 parent 14279d5 commit 129116f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions fastcrud/endpoint/helper.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Union, Annotated, Sequence
from typing import Type, Union, Annotated, Sequence
from pydantic import BaseModel, Field, ValidationError
from pydantic.functional_validators import field_validator

from sqlalchemy import inspect
from sqlalchemy import Column, TypeDecorator, inspect
from sqlalchemy.orm import DeclarativeBase
from sqlalchemy.sql.elements import KeyedColumnElement

Expand Down Expand Up @@ -43,10 +43,10 @@ def check_valid_method(cls, values: Sequence[str]) -> Sequence[str]:


def _get_primary_key(model: type[DeclarativeBase]) -> Union[str, None]:
return _get_primary_keys(model)[0]
return _get_primary_keys(model)[0].name


def _get_primary_keys(model: DeclarativeBase) -> Union[str, None]:
def _get_primary_keys(model: type[DeclarativeBase]) -> Sequence[Column]:
"""Get the primary key of a SQLAlchemy model."""
inspector = inspect(model).mapper
primary_key_columns = inspector.primary_key
Expand All @@ -58,7 +58,7 @@ def _get_primary_keys(model: DeclarativeBase) -> Union[str, None]:
try:
pk.type.python_type
except NotImplementedError:
pk.type.__class__.python_type = pk.type.__class__.impl.python_type
pk.type.__class__.python_type = pk.type.__class__.impl.python_type # type: ignore

return primary_key_columns

Expand Down

0 comments on commit 129116f

Please sign in to comment.