File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -1132,6 +1132,26 @@ def __annotate__(self):
11321132 {"x" : "int" },
11331133 )
11341134
1135+ def test_non_function_annotate (self ):
1136+ class AnnotateCallable :
1137+ def __call__ (self , format , / ):
1138+ if format > 2 :
1139+ raise NotImplementedError
1140+ return {"x" : int }
1141+
1142+ class OnlyAnnotate :
1143+ @property
1144+ def __annotate__ (self ):
1145+ return AnnotateCallable ()
1146+
1147+ oa = OnlyAnnotate ()
1148+ self .assertEqual (get_annotations (oa , format = Format .VALUE ), {"x" : int })
1149+ self .assertEqual (get_annotations (oa , format = Format .FORWARDREF ), {"x" : int })
1150+ self .assertEqual (
1151+ get_annotations (oa , format = Format .STRING ),
1152+ {"x" : "int" },
1153+ )
1154+
11351155 def test_non_dict_annotate (self ):
11361156 class WeirdAnnotate :
11371157 def __annotate__ (self , * args , ** kwargs ):
You can’t perform that action at this time.
0 commit comments