Files
ruff/crates/ty_python_semantic/resources/mdtest/external/strawberry.md
Aria Desires ad3de4e488 [ty] Improve rendering of default values for function args (#22010)
## Summary

We're actually quite good at computing this but the main issue is just
that we compute it at the type-level and so wrap it in `Literal[...]`.
So just special-case the rendering of these to omit `Literal[...]` and
fallback to `...` in cases where the thing we'll show is probably
useless (i.e. `x: str = str`).

Fixes https://github.com/astral-sh/ty/issues/1882
2025-12-16 13:39:19 -05:00

480 B

Strawberry GraphQL

[environment]
python-version = "3.13"
python-platform = "linux"

[project]
dependencies = ["strawberry-graphql==0.283.3"]

Basic model

import strawberry

@strawberry.type
class User:
    id: int
    role: str = strawberry.field(default="user")

reveal_type(User.__init__)  # revealed: (self: User, *, id: int, role: str = ...) -> None

user = User(id=1)
reveal_type(user.id)  # revealed: int
reveal_type(user.role)  # revealed: str