Skip to content

Commit

Permalink
[red-knot] Add test for nested attribute access
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed Jan 23, 2025
1 parent ce81103 commit 27e0961
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions crates/red_knot_python_semantic/resources/mdtest/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 27e0961

Please sign in to comment.