ruff/crates/red_knot_python_semantic
Douglas Creager 9db63fc58c
[red-knot] Handle generic constructors of generic classes (#17552)
We now handle generic constructor methods on generic classes correctly:

```py
class C[T]:
    def __init__[S](self, t: T, s: S): ...

x = C(1, "str")
```

Here, constructing `C` requires us to infer a specialization for the
generic contexts of `C` and `__init__` at the same time.

At first I thought I would need to track the full stack of nested
generic contexts here (since the `[S]` context is nested within the
`[T]` context). But I think this is the only way that we might need to
specialize more than one generic context at once — in all other cases, a
containing generic context must be specialized before we get to a nested
one, and so we can just special-case this.

While we're here, we also construct the generic context for a generic
function lazily, when its signature is accessed, instead of eagerly when
inferring the function body.
2025-04-23 15:06:18 -04:00
..
resources [red-knot] Handle generic constructors of generic classes (#17552) 2025-04-23 15:06:18 -04:00
src [red-knot] Handle generic constructors of generic classes (#17552) 2025-04-23 15:06:18 -04:00
tests [red-knot] Add GitHub PR annotations when mdtests fail in CI (#17150) 2025-04-02 21:51:52 +01:00
build.rs Modernize build scripts (#13837) 2024-10-20 22:35:35 +01:00
Cargo.toml [red-knot] Add a test to ensure that KnownClass::try_from_file_and_name() is kept up to date (#16326) 2025-02-24 12:14:20 +00:00
mdtest.py mdtest.py: do a full mdtest run immediately when the script is executed (#17128) 2025-04-01 19:27:55 +01:00
mdtest.py.lock [red-knot] Markdown test runner (#15632) 2025-01-21 14:06:35 +01:00