ruff/crates/ty_python_semantic/resources/mdtest
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
..
annotations [ty] Don't use implicit superclass annotation when converting a class constructor into a Callable (#22011) 2025-12-16 13:37:11 -05:00
assignment [ty] Improve diagnostics for unsupported binary operations and unsupported augmented assignments (#21947) 2025-12-12 21:53:29 +00:00
binary [ty] highlight special type syntax in hovers as xml (#22005) 2025-12-16 14:20:35 +00:00
boolean
boundness_declaredness
call [ty] propagate classmethod-ness through decorators returning Callables (#21958) 2025-12-16 09:16:40 -08:00
class [ty] highlight special type syntax in hovers as xml (#22005) 2025-12-16 14:20:35 +00:00
comparison [ty] Improve diagnostics for unsupported comparison operations (#21737) 2025-12-02 19:58:45 +00:00
comprehensions
conditional [ty] Uniformly use "not supported" in diagnostics (#21916) 2025-12-11 15:03:55 +00:00
dataclasses [ty] Infer typevar specializations for Callable types (#21551) 2025-12-16 09:16:49 -08:00
declaration
diagnostics [ty] Emit diagnostic when a type variable with a default is followed by one without a default (#21787) 2025-12-14 19:35:37 +00:00
directives [ty] Minor improvements to assert_type diagnostics (#21811) 2025-12-05 12:33:30 +00:00
doc
exception
expression [ty] Uniformly use "not supported" in diagnostics (#21916) 2025-12-11 15:03:55 +00:00
external [ty] Type inference for @asynccontextmanager (#21876) 2025-12-09 22:49:00 +01:00
function [ty] highlight special type syntax in hovers as xml (#22005) 2025-12-16 14:20:35 +00:00
generics [ty] Infer typevar specializations for Callable types (#21551) 2025-12-16 09:16:49 -08:00
ide_support
import [ty] highlight special type syntax in hovers as xml (#22005) 2025-12-16 14:20:35 +00:00
libraries
literal
loops [ty] Uniformly use "not supported" in diagnostics (#21916) 2025-12-11 15:03:55 +00:00
narrow [ty] highlight special type syntax in hovers as xml (#22005) 2025-12-16 14:20:35 +00:00
regression [ty] Use unqualified names for displays of TypeAliasTypes and unbound ParamSpecs/TypeVars (#21960) 2025-12-13 20:23:16 +00:00
scopes [ty] Add support for __qualname__ and other implicit class attributes (#21966) 2025-12-13 17:10:25 -05:00
shadowing
snapshots [ty] Infer typevar specializations for Callable types (#21551) 2025-12-16 09:16:49 -08:00
stubs
subscript [ty] support type[tuple[...]] (#21652) 2025-12-01 11:49:26 +01:00
suppressions [ty] Add code action to ignore diagnostic on the current line (#21595) 2025-11-29 15:41:54 +01:00
type_compendium
type_of [ty] Fix disjointness checks with type-of @final classes (#21770) 2025-12-10 15:15:10 -05:00
type_properties [ty] Fix disjointness checks with type-of @final classes (#21770) 2025-12-10 15:15:10 -05:00
type_qualifiers [ty] Avoid double-analyzing tuple in Final subscript (#21828) 2025-12-07 14:27:14 +00:00
unary [ty] Improve diagnostics for unsupported binary operations and unsupported augmented assignments (#21947) 2025-12-12 21:53:29 +00:00
with [ty] Type inference for @asynccontextmanager (#21876) 2025-12-09 22:49:00 +01:00
.mdformat.toml
async.md [ty] Infer typevar specializations for Callable types (#21551) 2025-12-16 09:16:49 -08:00
attributes.md [ty] Enable even more goto-definition on inlay hints (#21950) 2025-12-12 12:57:38 -05:00
bidirectional.md [ty] Improve diagnostics for unsupported comparison operations (#21737) 2025-12-02 19:58:45 +00:00
classes.md
cycle.md [ty] avoid fixpoint unioning of types containing current-cycle Divergent (#21910) 2025-12-11 19:52:34 -08:00
decorators.md [ty] Infer typevar specializations for Callable types (#21551) 2025-12-16 09:16:49 -08:00
del.md
deprecated.md [ty] Infer typevar specializations for Callable types (#21551) 2025-12-16 09:16:49 -08:00
descriptor_protocol.md [ty] Enable even more goto-definition on inlay hints (#21950) 2025-12-12 12:57:38 -05:00
enums.md
exhaustiveness_checking.md [ty] Exhaustiveness checking for generic classes (#21726) 2025-12-01 13:52:36 +01:00
final.md [ty] Improve @override, @final and Liskov checks in cases where there are multiple reachable definitions (#21767) 2025-12-03 12:51:36 +00:00
implicit_type_aliases.md [ty] highlight special type syntax in hovers as xml (#22005) 2025-12-16 14:20:35 +00:00
instance_layout_conflict.md
intersection_types.md
invalid_syntax.md [ty] Avoid double-inference on non-tuple argument to Annotated (#21837) 2025-12-08 10:24:05 -05:00
known_constants.md
liskov.md [ty] Carry generic context through when converting class into Callable (#21798) 2025-12-05 08:57:21 -05:00
literal_promotion.md [ty] Infer typevar specializations for Callable types (#21551) 2025-12-16 09:16:49 -08:00
mdtest_config.md
mdtest_custom_typeshed.md
metaclass.md
mro.md [ty] highlight special type syntax in hovers as xml (#22005) 2025-12-16 14:20:35 +00:00
named_tuple.md [ty] Support implicit type of cls in signatures (#21771) 2025-12-10 16:56:20 -05:00
overloads.md [ty] Improve check enforcing that an overloaded function must have an implementation (#21978) 2025-12-15 08:56:35 +00:00
override.md [ty] Improve @override, @final and Liskov checks in cases where there are multiple reachable definitions (#21767) 2025-12-03 12:51:36 +00:00
pep613_type_aliases.md [ty] highlight special type syntax in hovers as xml (#22005) 2025-12-16 14:20:35 +00:00
pep695_type_aliases.md [ty] Use unqualified names for displays of TypeAliasTypes and unbound ParamSpecs/TypeVars (#21960) 2025-12-13 20:23:16 +00:00
properties.md [ty] Enable even more goto-definition on inlay hints (#21950) 2025-12-12 12:57:38 -05:00
protocols.md Fix stack overflow with recursive generic protocols (depth limit) (#21858) 2025-12-09 09:05:18 -08:00
public_types.md
statically_known_branches.md
sys_platform.md
sys_version_info.md
t_strings.md
terminal_statements.md
ty_extensions.md [ty] Uniformly use "not supported" in diagnostics (#21916) 2025-12-11 15:03:55 +00:00
typed_dict.md [ty] add SyntheticTypedDictType and implement normalized and is_equivalent_to (#21784) 2025-12-10 20:36:36 +00:00
union_types.md
unpacking.md
unreachable.md