@@ -609,8 +609,8 @@ class Singular(HasTraits):
609609 """A base class that ensures only one instance of a class exists for each unique
610610 key (except for None).
611611
612- This class uses a class-level dictionary `_single_instances ` to store instances,
613- keyed by a value obtained from the `get_single_key` method . Subsequent calls to
612+ This class uses a class-level dictionary `_singular_instances ` to store instances,
613+ keyed by a value obtained from the `get_single_key` classmethod . Subsequent calls to
614614 the constructor with the same key will return the existing instance. If key is
615615 None, a new instance is always created and a reference is not kept to the object.
616616
@@ -619,13 +619,13 @@ class Singular(HasTraits):
619619 """
620620
621621 singular_init_started = traitlets .Bool (read_only = True )
622- _single_instances : ClassVar [dict [Hashable , Self ]] = {}
622+ _singular_instances : ClassVar [dict [Hashable , Self ]] = {}
623623 single_key = AnyTrait (default_value = None , allow_none = True , read_only = True )
624624 closed = Bool (read_only = True )
625625 singular : ClassVar [_SingularInstances [Self ]]
626626
627627 def __init_subclass__ (cls ) -> None :
628- cls ._single_instances = {}
628+ cls ._singular_instances = {}
629629 cls .singular = _SingularInstances ()
630630
631631 @classmethod
@@ -634,11 +634,11 @@ def get_single_key(cls, *args, **kwgs) -> Hashable: # noqa: ARG003
634634
635635 def __new__ (cls , / , * args , ** kwgs ) -> Self :
636636 key = cls .get_single_key (* args , ** kwgs )
637- if key is None or not (inst := cls ._single_instances .get (key )):
637+ if key is None or not (inst := cls ._singular_instances .get (key )):
638638 new = super ().__new__
639639 inst = new (cls ) if new is object .__new__ else new (cls , * args , ** kwgs )
640640 if key :
641- cls ._single_instances [key ] = inst
641+ cls ._singular_instances [key ] = inst
642642 inst .set_trait ("single_key" , key )
643643 return inst
644644
@@ -647,13 +647,13 @@ def __init__(self, /, *args, **kwgs):
647647 return
648648 self .set_trait ("singular_init_started" , True )
649649 super ().__init__ (* args , ** kwgs )
650- self .singular .set_trait ("instances" , tuple (self ._single_instances .values ()))
650+ self .singular .set_trait ("instances" , tuple (self ._singular_instances .values ()))
651651
652652 @observe ("closed" )
653653 def _singular_observe_closed (self , _ ):
654654 if self .closed and self .single_key is not None :
655- self ._single_instances .pop (self .single_key , None )
656- self .singular .set_trait ("instances" , tuple (self ._single_instances .values ()))
655+ self ._singular_instances .pop (self .single_key , None )
656+ self .singular .set_trait ("instances" , tuple (self ._singular_instances .values ()))
657657
658658 def close (self ):
659659 if close := getattr (super (), "close" , None ):
0 commit comments