[ty] Do not look up __init__ on instances (#18092)

## Summary

Dunder methods are never looked up on instances. We do this implicitly
in `try_call_dunder`, but the corresponding flag was missing in the
instance-construction code where we use `member_lookup_with_policy`
directly.

fixes https://github.com/astral-sh/ty/issues/322

## Test Plan

Added regression test.
This commit is contained in:
David Peter 2025-05-14 15:33:42 +02:00 committed by GitHub
parent 1eab59e681
commit 97d7b46936
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 27 additions and 1 deletions

View file

@ -4516,7 +4516,8 @@ impl<'db> Type<'db> {
.member_lookup_with_policy(
db,
"__init__".into(),
MemberLookupPolicy::MRO_NO_OBJECT_FALLBACK,
MemberLookupPolicy::NO_INSTANCE_FALLBACK
| MemberLookupPolicy::MRO_NO_OBJECT_FALLBACK,
)
.symbol
.is_unbound()