KotlinIsland / KotlinIsland/basedmypy

`ContainingClass` special form

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

Description

this scenario is pretty niche, but i think it shows a missing capability in the type system:

```py
from basedtyping import ContainingClass

class MyFunction:
def __init__(self, fn: Callable[[ContainingClass], object]

class A:
a = MyFunction(lambda self: self.b)
# 'self' inferred as A/Self
b: int
```

additionally, this could be used to model the special cased behavior of `FunctionType`

Contributor guide

Open the contributing guide

Research direction

Start by studying the ContainingClass example in the issue and the existing type-system handling for Callable and FunctionType. Determine how the proposed special form should infer self as A or Self, and define the expected behavior for the FunctionType case. Done means the capability is specified and both scenarios are covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
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.