File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -2134,6 +2134,12 @@ class or its subclasses. Our implementation is quite different
21342134 super ().__init__ (** kwargs )
21352135
21362136 def validate (self , obj , value ):
2137+ # We can't do resolve the classes in subclass_init because that
2138+ # might be called before all imports are done.
2139+ # but instance_init will give us runtime overhead for every trait
2140+ # (even those that are not set / None).
2141+ # This place is a good compromise.
2142+ self ._resolve_classes ()
21372143 assert self .klass is not None
21382144 if isinstance (value , self .klass ): # type:ignore[arg-type]
21392145 return value
@@ -2149,10 +2155,8 @@ def info(self):
21492155 result += " or None"
21502156 return result
21512157
2152- def instance_init (self , obj ):
2153- # we can't do this in subclass_init because that
2154- # might be called before all imports are done.
2155- self ._resolve_classes ()
2158+ def subclass_init (self , cls ):
2159+ pass
21562160
21572161 def _resolve_classes (self ):
21582162 if isinstance (self .klass , str ):
You can’t perform that action at this time.
0 commit comments