[red-knot] Use Unknown | T_inferred for undeclared public symbols (#15674)

## Summary

Use `Unknown | T_inferred` as the type for *undeclared* public symbols.

## Test Plan

- Updated existing tests
- New test for external `__slots__` modifications.
- New tests for external modifications of public symbols.
This commit is contained in:
David Peter
2025-01-24 12:47:48 +01:00
committed by GitHub
parent 7778d1d646
commit 1feb3cf41a
23 changed files with 212 additions and 91 deletions

View File

@@ -262,7 +262,8 @@ class A:
class B:
__add__ = A()
reveal_type(B() + B()) # revealed: int
# TODO: this could be `int` if we declare `B.__add__` using a `Callable` type
reveal_type(B() + B()) # revealed: Unknown | int
```
## Integration test: numbers from typeshed