@@ -20,10 +20,9 @@ def modify(self, prop: _schema.Property):
20
20
def negate (self ) -> _schema .PropertyModifier :
21
21
return _ChildModifier (False )
22
22
23
- # make ~doc same as doc(None)
24
-
25
23
26
24
class _DocModifierMetaclass (type (_schema .PropertyModifier )):
25
+ # make ~doc same as doc(None)
27
26
def __invert__ (self ) -> _schema .PropertyModifier :
28
27
return _DocModifier (None )
29
28
@@ -41,8 +40,8 @@ def negate(self) -> _schema.PropertyModifier:
41
40
return _DocModifier (None )
42
41
43
42
44
- # make ~desc same as desc(None)
45
43
class _DescModifierMetaclass (type (_schema .PropertyModifier )):
44
+ # make ~desc same as desc(None)
46
45
def __invert__ (self ) -> _schema .PropertyModifier :
47
46
return _DescModifier (None )
48
47
@@ -249,7 +248,18 @@ def annotate(annotated_cls: type) -> _Callable[[type], _PropertyAnnotation]:
249
248
def decorator (cls : type ) -> _PropertyAnnotation :
250
249
if cls .__name__ != "_" :
251
250
raise _schema .Error ("Annotation classes must be named _" )
252
- annotated_cls .__doc__ = cls .__doc__
251
+ if cls .__doc__ is not None :
252
+ annotated_cls .__doc__ = cls .__doc__
253
+ old_pragmas = getattr (annotated_cls , "_pragmas" , None )
254
+ new_pragmas = getattr (cls , "_pragmas" , [])
255
+ if old_pragmas :
256
+ old_pragmas .extend (new_pragmas )
257
+ else :
258
+ annotated_cls ._pragmas = new_pragmas
259
+ for a , v in cls .__dict__ .items ():
260
+ # transfer annotations
261
+ if a .startswith ("_" ) and not a .startswith ("__" ) and a != "_pragmas" :
262
+ setattr (annotated_cls , a , v )
253
263
for p , a in cls .__annotations__ .items ():
254
264
if p in annotated_cls .__annotations__ :
255
265
annotated_cls .__annotations__ [p ] |= a
0 commit comments