Coverage for sources/classcore/nomina.py: 100%

21 statements  

« prev     ^ index     » next       coverage.py v7.9.0, created at 2025-06-12 01:35 +0000

1# vim: set filetype=python fileencoding=utf-8: 

2# -*- coding: utf-8 -*- 

3 

4#============================================================================# 

5# # 

6# Licensed under the Apache License, Version 2.0 (the "License"); # 

7# you may not use this file except in compliance with the License. # 

8# You may obtain a copy of the License at # 

9# # 

10# http://www.apache.org/licenses/LICENSE-2.0 # 

11# # 

12# Unless required by applicable law or agreed to in writing, software # 

13# distributed under the License is distributed on an "AS IS" BASIS, # 

14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # 

15# See the License for the specific language governing permissions and # 

16# limitations under the License. # 

17# # 

18#============================================================================# 

19 

20 

21''' Catalog of common type aliases. ''' 

22 

23 

24from . import __ 

25 

26 

27AttributesNamer: __.typx.TypeAlias = __.cabc.Callable[ [ str, str ], str ] 

28 

29Decorator: __.typx.TypeAlias = __.typx.Annotated[ 

30 __.cabc.Callable[ [ type[ __.U ] ], type[ __.U ] ], 

31 __.dynadoc.Doc( 

32 ''' Class decorator. 

33 

34 Takes class argument and returns class. 

35 ''' ), 

36] 

37Decorators: __.typx.TypeAlias = __.typx.Annotated[ 

38 __.cabc.Sequence[ Decorator[ __.U ] ], __.dynadoc.Fname( 'decorators' ) 

39] 

40DecoratorsMutable: __.typx.TypeAlias = __.typx.Annotated[ 

41 __.cabc.MutableSequence[ Decorator[ __.U ] ], 

42 __.dynadoc.Fname( 'decorators' ), 

43 __.dynadoc.Doc( 

44 ''' Decorators may be inserted or removed from sequence. ''' ), 

45] 

46 

47DecorationPreparer: __.typx.TypeAlias = ( 

48 __.cabc.Callable[ [ type[ __.U ], DecoratorsMutable[ __.U ] ], None ] ) 

49DecorationPreparers: __.typx.TypeAlias = ( 

50 __.cabc.Sequence[ DecorationPreparer[ __.U ] ] ) 

51DecorationPreparersFactory: __.typx.TypeAlias = ( 

52 __.cabc.Callable[ [ ], DecorationPreparers[ __.U ] ] ) 

53 

54ClassConstructorLigation: __.typx.TypeAlias = __.typx.Annotated[ 

55 __.cabc.Callable[ ..., type ], 

56 __.dynadoc.Doc( 

57 ''' Bound class constructor function. 

58 

59 Usually from ``super( ).__new__`` or a partial function. 

60 ''' ), 

61] 

62InitializerLigation: __.typx.TypeAlias = __.typx.Annotated[ 

63 __.cabc.Callable[ ..., None ], 

64 __.dynadoc.Doc( 

65 ''' Bound initializer function. 

66 

67 Usually from ``super( ).__init__`` or a partial function. 

68 ''' ), 

69] 

70AssignerLigation: __.typx.TypeAlias = __.typx.Annotated[ 

71 __.cabc.Callable[ [ str, __.typx.Any ], None ], 

72 __.dynadoc.Doc( 

73 ''' Bound attributes assigner function. 

74 

75 Usually from ``super( ).__setattr__`` or a partial function. 

76 ''' ), 

77] 

78DeleterLigation: __.typx.TypeAlias = __.typx.Annotated[ 

79 __.cabc.Callable[ [ str ], None ], 

80 __.dynadoc.Doc( 

81 ''' Bound attributes deleter function. 

82 

83 Usually from ``super( ).__delattr__`` or a partial function. 

84 ''' ), 

85] 

86SurveyorLigation: __.typx.TypeAlias = __.typx.Annotated[ 

87 __.cabc.Callable[ [ ], __.cabc.Iterable[ str ] ], 

88 __.dynadoc.Doc( 

89 ''' Bound attributes surveyor function. 

90 

91 Usually from ``super( ).__dir__`` or a partial function. 

92 ''' ), 

93] 

94 

95 

96ClassConstructionPreprocessor: __.typx.TypeAlias = __.typx.Annotated[ 

97 __.cabc.Callable[ 

98 [ 

99 type[ type ], # metaclass 

100 str, # class name 

101 list[ type ], # bases (mutable) 

102 dict[ str, __.typx.Any ], # namespace (mutable) 

103 dict[ str, __.typx.Any ], # arguments (mutable) 

104 DecoratorsMutable[ __.U ], # decorators (mutable) 

105 ], 

106 None 

107 ], 

108 __.dynadoc.Doc( 

109 ''' Processes class data before construction. 

110 

111 For use cases, such as argument conversion. 

112 ''' ), 

113] 

114ClassConstructionPostprocessor: __.typx.TypeAlias = __.typx.Annotated[ 

115 __.cabc.Callable[ [ type, DecoratorsMutable[ __.U ] ], None ], 

116 __.dynadoc.Doc( 

117 ''' Processes class before decoration. 

118 

119 For use cases, such as decorator list manipulation. 

120 ''' ), 

121] 

122# TODO: ClassInitializationPreparer (arguments mutation) 

123ClassInitializationCompleter: __.typx.TypeAlias = __.typx.Annotated[ 

124 __.cabc.Callable[ [ type ], None ], 

125 __.dynadoc.Doc( 

126 ''' Completes initialization of class. 

127 

128 For use cases, such as enabling immutability once all other 

129 initialization has occurred. 

130 ''' ), 

131] 

132 

133 

134ClassConstructor: __.typx.TypeAlias = __.typx.Annotated[ 

135 __.cabc.Callable[ 

136 [ 

137 type, 

138 ClassConstructorLigation, 

139 str, 

140 tuple[ type, ... ], 

141 dict[ str, __.typx.Any ], 

142 __.NominativeArguments, 

143 Decorators[ __.U ], 

144 ], 

145 type 

146 ], 

147 __.dynadoc.Doc( ''' Constructor to use with metaclass. ''' ), 

148] 

149ClassInitializer: __.typx.TypeAlias = __.typx.Annotated[ 

150 __.cabc.Callable[ 

151 [ 

152 type, 

153 InitializerLigation, 

154 __.PositionalArguments, 

155 __.NominativeArguments, 

156 ], 

157 None 

158 ], 

159 __.dynadoc.Doc( ''' Initializer to use with metaclass. ''' ), 

160] 

161 

162 

163ProduceConstructorPreprocsArgument: __.typx.TypeAlias = __.typx.Annotated[ 

164 __.cabc.Sequence[ ClassConstructionPreprocessor[ __.U ] ], 

165 __.dynadoc.Doc( 

166 ''' Processors to apply before construction of class. ''' ), 

167] 

168ProduceConstructorPostprocsArgument: __.typx.TypeAlias = __.typx.Annotated[ 

169 __.cabc.Sequence[ ClassConstructionPostprocessor[ __.U ] ], 

170 __.dynadoc.Doc( 

171 ''' Processors to apply before decoration of class. ''' ), 

172] 

173ProduceInitializerCompletersArgument: __.typx.TypeAlias = __.typx.Annotated[ 

174 __.cabc.Sequence[ ClassInitializationCompleter ], 

175 __.dynadoc.Doc( 

176 ''' Processors to apply at final stage of class initialization. ''' ), 

177]