@@ -20,10 +20,9 @@ def modify(self, prop: _schema.Property):
2020 def negate (self ) -> _schema .PropertyModifier :
2121 return _ChildModifier (False )
2222
23- # make ~doc same as doc(None)
24-
2523
2624class _DocModifierMetaclass (type (_schema .PropertyModifier )):
25+ # make ~doc same as doc(None)
2726 def __invert__ (self ) -> _schema .PropertyModifier :
2827 return _DocModifier (None )
2928
@@ -41,8 +40,8 @@ def negate(self) -> _schema.PropertyModifier:
4140 return _DocModifier (None )
4241
4342
44- # make ~desc same as desc(None)
4543class _DescModifierMetaclass (type (_schema .PropertyModifier )):
44+ # make ~desc same as desc(None)
4645 def __invert__ (self ) -> _schema .PropertyModifier :
4746 return _DescModifier (None )
4847
@@ -249,7 +248,18 @@ def annotate(annotated_cls: type) -> _Callable[[type], _PropertyAnnotation]:
249248 def decorator (cls : type ) -> _PropertyAnnotation :
250249 if cls .__name__ != "_" :
251250 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 )
253263 for p , a in cls .__annotations__ .items ():
254264 if p in annotated_cls .__annotations__ :
255265 annotated_cls .__annotations__ [p ] |= a
0 commit comments