fastapi-users-db-sqlalchemy icon indicating copy to clipboard operation
fastapi-users-db-sqlalchemy copied to clipboard

fix: add mapped types in TYPE_CHECKING block for all cols

Open jd-solanki opened this issue 1 year ago • 1 comments

Hi @frankie567 👋🏻

I've been playing with fastapi-users and I have to remove unique constaint on email col due to soft deletes. Hence, I added my own email col however as I've email col like this:

    email: Mapped[str] = mapped_column(
        String(length=320),
        index=True,
        nullable=False,
        kw_only=True,
    )

'm getting error from pylance `Override type "Mapped[str]" is not the same as base type: image

Hence, I added unique of Mapped as well.

However, I can't understand why we need seperate if TYPE_CHECKING:? If we directly write cols like normal table it should work. If removing if TYPE_CHECKING: we can reject this PR as problem should solve automatically as now type will be same.

Big Thanks for this lib ❤️

jd-solanki avatar Oct 17 '24 08:10 jd-solanki

I'm not expert here but I guess this also relates to UserProtocol in models.py

jd-solanki avatar Oct 17 '24 08:10 jd-solanki