pyrefly icon indicating copy to clipboard operation
pyrefly copied to clipboard

Auto-complete for SQLAlchemy isn't working in VS Code (Pyrefly 1.4.1)

Open Desalutar20 opened this issue 2 weeks ago • 3 comments

Describe the Bug

https://github.com/user-attachments/assets/4496d24b-1c34-4721-9c06-771eed81d82a

The problem is with pyrefly because I changed the extension to ty and the tips started working.

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

Visual Studio Code Pyrefly 1.4.1

Desalutar20 avatar Nov 15 '26 06:11 Desalutar20

Thanks for the report and the video! Could you paste a small code sample (the model definition and the line where completion stops working) and your SQLAlchemy version, so we can reproduce it?

shahhamdihassan avatar Nov 19 '26 19:11 shahhamdihassan

from datetime import datetime
from uuid import UUID

from sqlalchemy import CheckConstraint, DateTime, String
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
from sqlalchemy.sql import text


class Model(DeclarativeBase):
    __abstract__ = True
    id: Mapped[UUID] = mapped_column(primary_key=True)
    created_at: Mapped[datetime] = mapped_column(
        DateTime(timezone=True), nullable=False
    )
    updated_at: Mapped[datetime] = mapped_column(
        DateTime(timezone=True), nullable=False
    )


class User(Model):
    __tablename__ = "users"
    __table_args__ = (
        CheckConstraint(
            "role IN ('admin', 'regular')",
            name="ck_users_role",
        ),
    )

    email: Mapped[str] = mapped_column(
        String(200), unique=True, nullable=False
    )
    password_hash: Mapped[str | None] = mapped_column(
        String(200), nullable=True
    )
    password_salt: Mapped[bytes | None] = mapped_column(nullable=True)
    first_name: Mapped[str | None] = mapped_column(
        String(50), nullable=True
    )
    last_name: Mapped[str | None] = mapped_column(
        String(50), nullable=True
    )
    role: Mapped[str] = mapped_column(server_default="regular", nullable=False)
    is_banned: Mapped[bool] = mapped_column(
        server_default=text("false"), nullable=False
    )
    is_verified: Mapped[bool] = mapped_column(
        server_default=text("false"), nullable=False
    )
    avatar_url: Mapped[str | None] = mapped_column(
        String(2000), nullable=True
    )
    github_id: Mapped[str | None] = mapped_column(
        String(200), nullable=True
    )
    google_id: Mapped[str | None] = mapped_column(
        String(200), nullable=True
    )

image

Desalutar20 avatar Nov 20 '26 03:11 Desalutar20

Thanks for the code sample! That gives us what we need to reproduce it. We'll take a look and follow up here.

shahhamdihassan avatar Nov 24 '26 23:11 shahhamdihassan