Skip to content

Commit

Permalink
Add test for redeclaration with a more static type
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed Feb 25, 2025
1 parent 1e24cdd commit ad83ea5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions crates/red_knot_python_semantic/resources/mdtest/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,23 @@ def _(flag: bool, flag1: bool, flag2: bool):
reveal_type(C().x) # revealed: Unknown | Literal[1, 2, 3]
```

### Possibly-unbound within gradual types

```py
from typing import Any

def _(flag: bool):
class Base:
x: Any

class Derived(Base):
if flag:
# Redeclaring `x` with a more static type is okay in terms of LSP.
x: int

reveal_type(Derived().x) # revealed: int | Any
```

### Attribute possibly unbound on a subclass but not on a superclass

```py
Expand Down

0 comments on commit ad83ea5

Please sign in to comment.