55from pvi .device import SignalR
66from pydantic import ValidationError
77
8- from fastcs .attributes import AttrR , AttrRW
8+ from fastcs .attributes import Attribute , AttrR , AttrRW
99from fastcs .backend import Backend
1010from fastcs .controller import Controller
1111from fastcs .datatypes import Bool , Enum , Float , Int , String
@@ -138,6 +138,15 @@ class ControllerWrongEnumClass(Controller):
138138 "Expected 'MyEnum', got 'MyEnum2'."
139139 )
140140
141+ class ControllerUnspecifiedAccessMode (Controller ):
142+ hinted : Attribute [int ]
143+
144+ async def initialise (self ):
145+ self .hinted = AttrR (Int ())
146+
147+ # no assertion thrown
148+ Backend (ControllerUnspecifiedAccessMode (), loop )
149+
141150
142151def test_hinted_attributes_verified_on_subcontrollers ():
143152 loop = asyncio .get_event_loop ()
@@ -155,3 +164,25 @@ async def initialise(self):
155164
156165 with pytest .raises (RuntimeError , match = "failed to introspect hinted attribute" ):
157166 Backend (TopController (), loop )
167+
168+
169+ def test_hinted_attribute_types_verified ():
170+ # test verification works with non-GenericAlias type hints
171+ loop = asyncio .get_event_loop ()
172+
173+ class ControllerAttrWrongAccessMode (Controller ):
174+ read_attr : AttrR
175+
176+ async def initialise (self ):
177+ self .read_attr = AttrRW (Int ())
178+
179+ with pytest .raises (RuntimeError , match = "does not match defined access mode" ):
180+ Backend (ControllerAttrWrongAccessMode (), loop )
181+
182+ class ControllerUnspecifiedAccessMode (Controller ):
183+ unspecified_access_mode : Attribute
184+
185+ async def initialise (self ):
186+ self .unspecified_access_mode = AttrRW (Int ())
187+
188+ Backend (ControllerUnspecifiedAccessMode (), loop )
0 commit comments