pyrefly
pyrefly copied to clipboard
Auto-complete for SQLAlchemy isn't working in VS Code (Pyrefly 1.4.1)
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
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?
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
)
Thanks for the code sample! That gives us what we need to reproduce it. We'll take a look and follow up here.