KotlinIsland / KotlinIsland/basedmypy
Narrow variables when `cast`
- Dominant language
- Python
- Stars
- 202
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Description
**Feature**
Usages of `cast` should narrow a variable
```py
def foo(a: A):
b = cast(B, a)
reveal_type(a) # expect: A & B, actual: A
reveal_type(b) # expect: B, actual: B
```
Allegedly, cast is only used for sus dynamic nonsense. I've heard basedtyping is planning on implementing a based cast that performs a lot more cool stuff and shouldn't require any implicit functionality.
Contributor guide
Research direction
The issue gives a Python example showing that cast(B, a) should narrow a to A & B while leaving the cast result as B. Start by locating the implementation and tests for cast handling and variable narrowing. Done means the example produces the expected revealed types and existing behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100