<reponame>adriangb/prisma-client-py<filename>typesafety/pyright/query_first.py<gh_stars>100-1000
from prisma import Client
from prisma.models import User


async def main(client: Client) -> None:
    user = await client.query_first('', model=User)
    reveal_type(user)  # T: User | None
    assert user is not None
    reveal_type(user)  # T: User
    reveal_type(user.id)  # T: str

    user.foo  # E: Cannot access member "foo" for type "User"

    result = await client.query_first('')
    reveal_type(result)  # T: Any

from prisma import Client
from prisma.models import User


async def main(client: Client) -> None:
    user = await client.query_first('', model=User)
    reveal_type(user)  # T: User | None
    assert user is not None
    reveal_type(user)  # T: User
    reveal_type(user.id)  # T: str

    user.foo  # E: Cannot access member "foo" for type "User"

    result = await client.query_first('')
    reveal_type(result)  # T: Any
# T: User | None # T: User # T: str # E: Cannot access member "foo" for type "User" # T: Any