Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

traitlets.Set should support generic type annotations for type safety

Open
#927 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
tooling

Research direction

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.

Written by the indexing model from the issue text.

Description

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

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:

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 as a container trait.

Dominant language
Python
Stars
653
Forks
217
Avg merge
2d 21h
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ipython/traitlets

All issues in ipython/traitlets

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.