traitlets.Set should support generic type annotations for type safety
- 主要言語
- Python
- スター
- 653
- フォーク
- 217
- 平均マージ
- 2日 21時間
- マージ済み PR(30日)
- 2
説明
## Problem
`traitlets.Set` currently lacks generic type support, making it impossible to specify the type of elements it contains for proper type checking.
## Current Situation
```python
from traitlets import Set
import traitlets
class MyClass(traitlets.HasTraits):
# This works but provides no type information
my_set = Set()
# This doesn't work - no generic support
# my_set: Set[str] = Set() # Type error
```
## Desired Behavior
`traitlets.Set` should support generic type annotations similar to how Python's built-in collections work:
```python
from traitlets import Set
import traitlets
class MyClass(traitlets.HasTraits):
# Should be possible for type safety
room_ids: Set[str] = Set()
numbers: Set[int] = Set(default_value={1, 2, 3})
```
## Reference
The `Set` class is implemented in [`traitlets/traitlets.py`](https://github.com/ipython/traitlets/blob/main/traitlets/traitlets.py) as a container trait.
コントリビューションガイド
調査の方向性
Start in traitlets/traitlets.py at the Set container trait implementation and inspect how its type parameters could correspond to the annotated element type. Done means Set accepts annotations such as Set[str] and Set[int] while preserving the existing default-value behavior; the issue does not name a test file or test entry point.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- tooling
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100