enthought / traits

Observable typed attributes for Python classes
Other
432 stars 85 forks source link

Document that handlers (e.g., `TraitType` subclasses) should be stateless #1720

Open mdickinson opened 2 years ago

mdickinson commented 2 years ago

I've seen a couple of instances recently where projects were trying to store per-object state in a TraitType instance. That doesn't work, in general: the TraitType instance is per-class, not per-object.

In the section of the user docs on writing your own TraitType subclass, it should be made clear that TraitType instances should be stateless: they shouldn't store per-object state from the HasTraits objects using them.