ruff/crates/red_knot_python_semantic/resources/mdtest/call
David Peter 18bac94226
[red-knot] Lookup of `__new__` (#17733)
## Summary

Model the lookup of `__new__` without going through
`Type::try_call_dunder`. The `__new__` method is only looked up on the
constructed type itself, not on the meta-type.

This now removes ~930 false positives across the ecosystem (vs 255 for
https://github.com/astral-sh/ruff/pull/17662). It introduces 30 new
false positives related to the construction of enums via something like
`Color = enum.Enum("Color", ["RED", "GREEN"])`. This is expected,
because we don't handle custom metaclass `__call__` methods. The fact
that we previously didn't emit diagnostics there was a coincidence (we
incorrectly called `EnumMeta.__new__`, and since we don't fully
understand its signature, that happened to work with `str`, `list`
arguments).

closes #17462

## Test Plan

Regression test
2025-04-30 17:27:09 +02:00
..
annotation.md red_knot_python_semantic: replace one use of "old" secondary diagnostic messages 2025-04-10 13:21:00 -04:00
builtins.md [red-knot] Three-argument type-calls take 'str' as the first argument (#17168) 2025-04-03 15:45:08 +02:00
callable_instance.md red_knot_python_semantic: replace one use of "old" secondary diagnostic messages 2025-04-10 13:21:00 -04:00
constructor.md [red-knot] Lookup of `__new__` (#17733) 2025-04-30 17:27:09 +02:00
dunder.md Fix member lookup for unions & intersections ignoring policy (#17066) 2025-03-31 09:40:47 +02:00
function.md [red-knot] Detect version-related syntax errors (#16379) 2025-04-17 14:00:30 -04:00
getattr_static.md [red-knot] improve function/bound method type display (#17294) 2025-04-14 15:56:18 -07:00
invalid_syntax.md red_knot_python_semantic: replace one use of "old" secondary diagnostic messages 2025-04-10 13:21:00 -04:00
methods.md [red-knot] Check overloads without an implementation (#17681) 2025-04-30 19:54:21 +05:30
never.md [red-knot] Never is callable and iterable. Arbitrary attributes can be accessed. (#16533) 2025-03-06 15:59:19 +00:00
str_startswith.md [red-knot] Specialize `str.startswith` for string literals (#17351) 2025-04-11 16:26:45 +02:00
subclass_of.md red_knot_python_semantic: replace one use of "old" secondary diagnostic messages 2025-04-10 13:21:00 -04:00
union.md [red-knot] fix collapsing literal and its negation to object (#17605) 2025-04-24 13:55:05 +00:00