mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 02:12:22 +00:00
[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:
parent
39e2df7ada
commit
1ecd97855e
1 changed files with 24 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue