KotlinIsland / KotlinIsland/basedmypy

narrow types under same constant condition

Open
#644 1 comment 0 reactions 0 assignees View on GitHub
feature p-2
Dominant language
Python
Stars
202
Forks
6
PR merge metrics
No merged PRs in 30d

Description

```py
a: Final[str]

if a == "a":
def f(): ...
if a == "a":
f()
```
this shouldn't be an error

also `possibly-undefined`:
```py
def func(x: bool):
if x:
msg = 'hello world'
if x:
print(msg)
```

Contributor guide

Open the contributing guide

Research direction

Reproduce both Python snippets in basedmypy and start by locating the checker logic for constant-condition narrowing and possibly-undefined diagnostics. Done means the repeated constant-condition function call and the second guarded use of msg no longer produce errors, with regression coverage for both cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.