KotlinIsland / KotlinIsland/basedmypy
Conditional types with `If`
- Dominant language
- Python
- Stars
- 202
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Description
Would make a lot of overloads simpler
```py
def foo(a: bool) -> If[a, str, int]:
if a:
return str(a)
return 1
def bar(s: str) -> If[s == "AMONGUS", str, int]:
if a == "AMONGUS":
return str(a)
return 1
```
In the same way that overloads are not checked, these also wouldn't be.
What about `if`?
```py
def foo(a: bool) -> str if a else int: ...
```
Contributor guide
Research direction
No file, test, or entry point is named. Start by tracing how basedmypy handles overload checking and parses function return annotations, then compare the proposed `If` form with the conditional `if` annotation form. Done would require a settled design for both forms and tests defining their supported behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100