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

21 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-04-29 22:58 +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 __future__ import annotations 

25 

26from . import __ 

27 

28 

29AttributesNamer: __.typx.TypeAlias = ( 

30 __.cabc.Callable[ [ str, str ], str ] ) 

31 

32Decorator: __.typx.TypeAlias = __.cabc.Callable[ [ type ], type ] 

33Decorators: __.typx.TypeAlias = __.cabc.Sequence[ Decorator ] 

34DecoratorsMutable: __.typx.TypeAlias = __.cabc.MutableSequence[ Decorator ] 

35 

36DecorationPreparer: __.typx.TypeAlias = ( 

37 __.cabc.Callable[ [ type, DecoratorsMutable ], None ] ) 

38DecorationPreparers: __.typx.TypeAlias = ( 

39 __.cabc.Sequence[ DecorationPreparer ] ) 

40 

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

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

43 __.typx.Doc( 

44 ''' Bound class constructor function. 

45 

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

47 ''' ), 

48] 

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

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

51 __.typx.Doc( 

52 ''' Bound initializer function. 

53 

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

55 ''' ), 

56] 

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

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

59 __.typx.Doc( 

60 ''' Bound attributes assigner function. 

61 

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

63 ''' ), 

64] 

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

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

67 __.typx.Doc( 

68 ''' Bound attributes deleter function. 

69 

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

71 ''' ), 

72] 

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

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

75 __.typx.Doc( 

76 ''' Bound attributes surveyor function. 

77 

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

79 ''' ), 

80] 

81 

82 

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

84 __.cabc.Callable[ 

85 [ 

86 type[ type ], # metaclass 

87 str, # class name 

88 list[ type ], # bases (mutable) 

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

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

91 DecoratorsMutable, # decorators (mutable) 

92 ], 

93 None 

94 ], 

95 __.typx.Doc( 

96 ''' Processes class data before construction. 

97 

98 For use cases, such as argument conversion. 

99 ''' ), 

100] 

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

102 __.cabc.Callable[ [ type, DecoratorsMutable ], None ], 

103 __.typx.Doc( 

104 ''' Processes class before decoration. 

105 

106 For use cases, such as decorator list manipulation. 

107 ''' ), 

108] 

109# TODO: ClassInitializationPreparer (arguments mutation) 

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

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

112 __.typx.Doc( 

113 ''' Completes initialization of class. 

114 

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

116 initialization has occurred. 

117 ''' ), 

118] 

119 

120 

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

122 __.cabc.Callable[ 

123 [ 

124 type, 

125 ClassConstructorLigation, 

126 str, 

127 tuple[ type, ... ], 

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

129 __.NominativeArguments, 

130 Decorators, 

131 ], 

132 type 

133 ], 

134 __.typx.Doc( ''' Constructor to use with metaclass. ''' ), 

135] 

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

137 __.cabc.Callable[ 

138 [ 

139 type, 

140 InitializerLigation, 

141 __.PositionalArguments, 

142 __.NominativeArguments, 

143 ], 

144 None 

145 ], 

146 __.typx.Doc( ''' Initializer to use with metaclass. ''' ), 

147] 

148 

149 

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

151 __.cabc.Sequence[ ClassConstructionPreprocessor ], 

152 __.typx.Doc( ''' Processors to apply before construction of class. ''' ), 

153] 

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

155 __.cabc.Sequence[ ClassConstructionPostprocessor ], 

156 __.typx.Doc( ''' Processors to apply before decoration of class. ''' ), 

157] 

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

159 __.cabc.Sequence[ ClassInitializationCompleter ], 

160 __.typx.Doc( 

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

162]