ruff/crates/ty_python_semantic/resources/mdtest/annotations
Douglas Creager 2214a46139
[ty] Don't use implicit superclass annotation when converting a class constructor into a `Callable` (#22011)
This fixes a bug @zsol found running ty against pyx. His original repro
is:

```py
class Base:
    def __init__(self) -> None: pass

class A(Base):
    pass

def foo[T](callable: Callable[..., T]) -> T:
    return callable()

a: A = foo(A)
```

The call at the bottom would fail, since we would infer `() -> Base` as
the callable type of `A`, when it should be `() -> A`.

The issue was how we add implicit annotations to `self` parameters.
Typically, we turn it into `self: Self`. But in cases where we don't
need to introduce a full typevar, we turn it into `self: [the class
itself]` — in this case, `self: Base`. Then, when turning the class
constructor into a callable, we would see this non-`Self` annotation and
think that it was important and load-bearing.

The fix is that we skip all implicit annotations when determining
whether the `self` annotation should take precedence in the callable's
return type.
2025-12-16 13:37:11 -05:00
..
annotated.md [ty] Support stringified annotations in value-position `Annotated` instances (#21447) 2025-11-14 13:09:09 +00:00
any.md [ty] highlight special type syntax in hovers as xml (#22005) 2025-12-16 14:20:35 +00:00
callable.md [ty] Don't use implicit superclass annotation when converting a class constructor into a `Callable` (#22011) 2025-12-16 13:37:11 -05:00
deferred.md [ty] fix global symbol lookup from eager scopes (#21317) 2025-11-12 10:15:51 -08:00
generic_alias.md [ty] Remove `GenericAlias`-related todo type (#21728) 2025-12-01 13:02:38 +00:00
int_float_complex.md [ty] Improve disjointness inference for `NominalInstanceType`s and `SubclassOfType`s (#18864) 2025-06-24 20:27:37 +00:00
invalid.md [ty] tighten up handling of subscripts in type expressions (#21503) 2025-11-18 10:43:07 -08:00
literal.md [ty] tighten up handling of subscripts in type expressions (#21503) 2025-11-18 10:43:07 -08:00
literal_string.md [ty] Improve several "Did you mean?" suggestions (#21597) 2025-11-25 10:29:01 +00:00
never.md [ty] highlight special type syntax in hovers as xml (#22005) 2025-12-16 14:20:35 +00:00
new_types.md [ty] support `NewType`s of `float` and `complex` (#21886) 2025-12-12 00:43:09 +00:00
optional.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
self.md [ty] Infer typevar specializations for `Callable` types (#21551) 2025-12-16 09:16:49 -08:00
starred.md [ty] Return `Option<TupleType>` from `infer_tuple_type_expression` (#19735) 2025-08-04 13:48:19 +01:00
stdlib_typing_aliases.md [ty] Fix bug where ty would think all types had an `__mro__` attribute (#20995) 2025-10-27 11:19:12 +00:00
string.md [ty] Avoid enforcing standalone expression for tests in f-strings (#21967) 2025-12-15 22:31:04 -05:00
union.md [ty] Implicit type aliases: Support for PEP 604 unions (#21195) 2025-11-03 21:50:25 +01:00
unsupported_special_forms.md [ty] Complete support for `ParamSpec` (#21445) 2025-12-05 22:00:06 +05:30
unsupported_special_types.md Generalize special-casing for enums constructed with the functional syntax (#17885) 2025-05-06 11:02:55 +01:00
unsupported_type_qualifiers.md [ty] validate constructor call of `TypedDict` (#19810) 2025-08-25 14:45:52 +02:00