File tree Expand file tree Collapse file tree 2 files changed +17
-7
lines changed
Expand file tree Collapse file tree 2 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -62,13 +62,12 @@ def validate_hinted_attributes(controller: BaseController):
6262 )
6363 if attr_class is not type (attr ):
6464 # skip validation if access mode not specified
65- if attr_class is Attribute and isinstance (attr , Attribute ):
66- continue
67- raise RuntimeError (
68- f"Controller '{ controller .__class__ .__name__ } ' introspection of hinted "
69- f"attribute '{ name } ' does not match defined access mode. "
70- f"Expected '{ attr_class .__name__ } ', got '{ type (attr ).__name__ } '."
71- )
65+ if not (attr_class is Attribute and isinstance (attr , Attribute )):
66+ raise RuntimeError (
67+ f"Controller '{ controller .__class__ .__name__ } ' introspection of "
68+ f"hinted attribute '{ name } ' does not match defined access mode. "
69+ f"Expected '{ attr_class .__name__ } ', got '{ type (attr ).__name__ } '."
70+ )
7271 if attr_dtype is not None and attr_dtype != attr .datatype .dtype :
7372 raise RuntimeError (
7473 f"Controller '{ controller .__class__ .__name__ } ' introspection of hinted "
Original file line number Diff line number Diff line change @@ -186,3 +186,14 @@ async def initialise(self):
186186 await controller .initialise ()
187187 # no assertion thrown
188188 validate_hinted_attributes (controller )
189+
190+ class ControllerUnspecifiedAccessModeWrongType (Controller ):
191+ unspecified_access_mode_wrong_type : Attribute [int ]
192+
193+ async def initialise (self ):
194+ self .unspecified_access_mode_wrong_type = AttrRW (Float ())
195+
196+ controller = ControllerUnspecifiedAccessModeWrongType ()
197+ await controller .initialise ()
198+ with pytest .raises (RuntimeError , match = "does not match defined datatype" ):
199+ validate_hinted_attributes (controller )
You can’t perform that action at this time.
0 commit comments