Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,21 @@ C[None](b"bytes") # error: [no-matching-overload]
C[None](12)
```

### Synthesized methods with dataclasses

```py
from dataclasses import dataclass
from typing import Generic, TypeVar

T = TypeVar("T")

@dataclass
class A(Generic[T]):
x: T

reveal_type(A(x=1)) # revealed: A[int]
```

## Generic subclass

When a generic subclass fills its superclass's type parameter with one of its own, the actual types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,18 @@ C[None](b"bytes") # error: [no-matching-overload]
C[None](12)
```

### Synthesized methods with dataclasses

```py
from dataclasses import dataclass

@dataclass
class A[T]:
x: T

reveal_type(A(x=1)) # revealed: A[int]
```

## Generic subclass

When a generic subclass fills its superclass's type parameter with one of its own, the actual types
Expand Down
4 changes: 1 addition & 3 deletions crates/ty_python_semantic/resources/mdtest/named_tuple.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,7 @@ class Property[T](NamedTuple):
name: str
value: T

# TODO: this should be supported (no error, revealed type of `Property[float]`)
# error: [invalid-argument-type]
reveal_type(Property("height", 3.4)) # revealed: Property[Unknown]
reveal_type(Property("height", 3.4)) # revealed: Property[float]
```

## Attributes on `NamedTuple`
Expand Down
3 changes: 2 additions & 1 deletion crates/ty_python_semantic/src/types/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,8 @@ impl<'db> ClassLiteral<'db> {
parameters.push(parameter);
}

let signature = Signature::new(Parameters::new(parameters), Some(Type::none(db)));
let mut signature = Signature::new(Parameters::new(parameters), Some(Type::none(db)));
signature.inherited_generic_context = self.generic_context(db);
Some(CallableType::function_like(db, signature))
};

Expand Down
Loading