[red-knot] Add test for nested attribute access (#15684)

## Summary

Add a new test for attribute accesses in case of nested modules /
classes. Resolves this comment:

https://github.com/astral-sh/ruff/pull/15613#discussion_r1925637561

## Test Plan

New MD test.
This commit is contained in:
David Peter 2025-01-23 10:26:34 +01:00 committed by GitHub
parent 39e2df7ada
commit 1ecd97855e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -470,6 +470,30 @@ for mod.global_symbol in IntIterable():
pass
```
## Nested attributes
```py path=outer/__init__.py
```
```py path=outer/nested/__init__.py
```
```py path=outer/nested/inner.py
class Outer:
class Nested:
class Inner:
attr: int = 1
```
```py
import outer.nested.inner
reveal_type(outer.nested.inner.Outer.Nested.Inner.attr) # revealed: int
# error: [invalid-assignment]
outer.nested.inner.Outer.Nested.Inner.attr = "a"
```
## Literal types
### Function-literal attributes