KotlinIsland / KotlinIsland/basedmypy
assert style type guards
- Dominant language
- Python
- Stars
- 202
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Description
```py
def f(x: object) -> TypeAssertion[int]: # demarcation is tentative, maybe `Asserts[x is int]`
assert isinstance(x, int)
a: object
f(a)
reveal_type(a) # int is
```
# Notes:
- Would want to be able to provide an assertion and a return type
```py
def f(x: object) -> Asserts[x is int] & str: ...
```
- Would want to be able to do 'truthy' assertions / invariants
```py
def asserts(x: object) -> Asserts[x] ...
a: object
asserts(isinstance(a, bool))
reveal_type(a) # bool
```
Contributor guide
Research direction
No file, test, or entry point is named. Start by locating the type-checker tests for annotations and type narrowing, then use the examples to define the assertion syntax and inference behavior. Done means supported assertion and return-type forms narrow the caller’s type as shown.
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