KotlinIsland / KotlinIsland/basedmypy

support types that are defined with values

Open
#790 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
202
Forks
6
PR merge metrics
No merged PRs in 30d

Description

```py
a: Final = 1
A = Literal[a]
# okay, because `a` is always 1

b: a = a
# okay, because `a` is always 1

class C ...
c: Final = C()
d: c = c # error
# bad because it's ambigious if the `c` here means instance `C` or `type[C]`, need to use `TypeOf[c]`
```

# use case

```py
@global_enum
class _A(Enum):
A = 1
A: Final = _A.A

a: _A.A = A # works
a: A = A # desired
```

Contributor guide

Open the contributing guide

Research direction

The issue provides Python examples using Final, Literal, Enum, and the proposed TypeOf syntax, but names no source files or tests. Start by reproducing the examples with the current type checker and tracing how these annotations are interpreted. Done means the stated value-defined type cases are supported without making the ambiguous class-instance case silently valid.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.