KotlinIsland / KotlinIsland/basedmypy

Add `Void` type

Open
#4 0 comments 1 reaction 0 assignees View on GitHub
basedtyping p-3 runtime
Dominant language
Python
Stars
202
Forks
6
PR merge metrics
No merged PRs in 30d

Description

A type that is distinct from `None` that serves the purpose of being useless.
All usages of it should be reported as warnings.

I wonder if `Void` should be the root type?

So in typing land `None` actually means `Void` when it's the sole return type.

But there are other use cases:
```py
fn1: Callable[[int], None] = lambda arg: arg
fn2: Callable[[int], Optional[str]] = fn1 # Note this assignment
value: Optional[str] = fn2(123) # value would be int actually

a: Callable[[], None] = lambda: 1
b: Callable[[], None | str] = a # INVALID!
v: str | None = b()
assert v
reveal_type(v) # str, but it's actually int
```

```py
a: Callable[[], int] = ...
b: Callable[[], Void] = a # valid, the return type is covariant and Void is the root type
v: str | Void = b() # probs an error?
assert not isinstance(b, Void)
reveal_type(v) # , unreachable
```

Contributor guide

Open the contributing guide

Research direction

The issue does not name any files, tests, or entry points to begin with. Clarify the semantics of Void, including its relationship to None, callable variance, unions, warnings, and root-type behavior, then define tests that establish the intended typing results.

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
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.