File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -85,7 +85,9 @@ class BaseLearner(metaclass=_RequireAttrsABCMeta):
8585 and returns a holoviews plot.
8686 """
8787
88- required_attributes = ["data" , "npoints" , "pending_points" ]
88+ data : dict
89+ npoints : int
90+ pending_points : set
8991
9092 def tell (self , x , y ):
9193 """Tell the learner about a single value.
Original file line number Diff line number Diff line change @@ -71,11 +71,14 @@ def decorator(method):
7171
7272
7373class _RequireAttrsABCMeta (abc .ABCMeta ):
74- required_attributes = []
75-
7674 def __call__ (self , * args , ** kwargs ):
7775 obj = super ().__call__ (* args , ** kwargs )
78- for name in obj .required_attributes :
76+ for name , type_ in obj .__annotations__ . items () :
7977 if not hasattr (obj , name ):
8078 raise ValueError (f"Required attribute { name } not set in __init__." )
79+ elif not isinstance (getattr (obj , name ), type_ ):
80+ raise TypeError (
81+ f"The attribute '{ name } ' is of { type_ } instead of { type (getattr (obj , name ))} "
82+ )
83+
8184 return obj
You can’t perform that action at this time.
0 commit comments