66from pvi .device import SignalR
77from pydantic import ValidationError
88
9- from fastcs .attributes import AttrR , AttrRW
9+ from fastcs .attributes import Attribute , AttrR , AttrRW
1010from fastcs .backend import Backend
1111from fastcs .controller import Controller
1212from fastcs .datatypes import Bool , Enum , Float , Int , String
@@ -127,6 +127,15 @@ class ControllerWrongEnumClass(Controller):
127127 "Expected 'MyEnum', got 'MyEnum2'."
128128 )
129129
130+ class ControllerUnspecifiedAccessMode (Controller ):
131+ hinted : Attribute [int ]
132+
133+ async def initialise (self ):
134+ self .hinted = AttrR (Int ())
135+
136+ # no assertion thrown
137+ Backend (ControllerUnspecifiedAccessMode (), loop )
138+
130139
131140def test_hinted_attributes_verified_on_subcontrollers ():
132141 loop = asyncio .get_event_loop ()
@@ -144,3 +153,25 @@ async def initialise(self):
144153
145154 with pytest .raises (RuntimeError , match = "failed to introspect hinted attribute" ):
146155 Backend (TopController (), loop )
156+
157+
158+ def test_hinted_attribute_types_verified ():
159+ # test verification works with non-GenericAlias type hints
160+ loop = asyncio .get_event_loop ()
161+
162+ class ControllerAttrWrongAccessMode (Controller ):
163+ read_attr : AttrR
164+
165+ async def initialise (self ):
166+ self .read_attr = AttrRW (Int ())
167+
168+ with pytest .raises (RuntimeError , match = "does not match defined access mode" ):
169+ Backend (ControllerAttrWrongAccessMode (), loop )
170+
171+ class ControllerUnspecifiedAccessMode (Controller ):
172+ unspecified_access_mode : Attribute
173+
174+ async def initialise (self ):
175+ self .unspecified_access_mode = AttrRW (Int ())
176+
177+ Backend (ControllerUnspecifiedAccessMode (), loop )
0 commit comments