You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
traitlets.Set should support generic type annotations for type safety #927
traitlets.Set currently lacks generic type support, making it impossible to specify the type of elements it contains for proper type checking.
Current Situation
fromtraitletsimportSetimporttraitletsclassMyClass(traitlets.HasTraits):
# This works but provides no type informationmy_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:
fromtraitletsimportSetimporttraitletsclassMyClass(traitlets.HasTraits):
# Should be possible for type safetyroom_ids: Set[str] =Set()
numbers: Set[int] =Set(default_value={1, 2, 3})
Activity