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

37 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-16 06:16 +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 names and type aliases. ''' 

22# ruff: noqa: F403,F405 

23 

24 

25from ..nomina import * 

26from . import __ 

27 

28concealment_label = 'concealment' 

29immutability_label = 'immutability' 

30 

31 

32abc_class_mutables = __.abc_class_mutables 

33typing_class_mutables = __.typing_class_mutables 

34AttrnameCalculator = __.AttrnameCalculator 

35 

36 

37BehaviorExclusionNames: __.typx.TypeAlias = __.cabc.Set[ str ] 

38BehaviorExclusionNamesOmni: __.typx.TypeAlias = ( 

39 BehaviorExclusionNames | __.typx.Literal[ '*' ] ) 

40BehaviorExclusionPredicate: __.typx.TypeAlias = ( 

41 __.cabc.Callable[ [ str ], bool ] ) 

42BehaviorExclusionPredicates: __.typx.TypeAlias = ( 

43 __.cabc.Sequence[ BehaviorExclusionPredicate ] ) 

44BehaviorExclusionRegex: __.typx.TypeAlias = __.re.Pattern[ str ] 

45BehaviorExclusionRegexes: __.typx.TypeAlias = ( 

46 __.cabc.Sequence[ BehaviorExclusionRegex ] ) 

47BehaviorExclusionVerifier: __.typx.TypeAlias = ( 

48 str | BehaviorExclusionRegex | BehaviorExclusionPredicate ) 

49BehaviorExclusionVerifiers: __.typx.TypeAlias = ( 

50 __.cabc.Sequence[ BehaviorExclusionVerifier ] ) 

51BehaviorExclusionVerifiersOmni: __.typx.TypeAlias = ( 

52 BehaviorExclusionVerifiers | __.typx.Literal[ '*' ] ) 

53InternalNameDetector: __.typx.TypeAlias = ( 

54 __.cabc.Callable[ [ str ], bool ] ) 

55InternalNameDetectors: __.typx.TypeAlias = ( 

56 __.cabc.Sequence[ InternalNameDetector ] ) 

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

58 __.cabc.Callable[ [ str ], type[ Exception ] ], 

59 __.ddoc.Doc( 

60 ''' Takes name of exception class and returns corresponding class. 

61 

62 Can be used by downstream packages to provide exceptions from their 

63 own hierarchies rather than the hierarchy from this package. 

64 ''' ), 

65] 

66 

67 

68class AssignerCore( __.typx.Protocol ): 

69 ''' Core implementation of attributes assigner. ''' 

70 

71 @staticmethod 

72 def __call__( # noqa: PLR0913 # pragma: no branch 

73 obj: object, /, *, 

74 ligation: AssignerLigation, 

75 attributes_namer: AttributesNamer, 

76 error_class_provider: ErrorClassProvider, 

77 level: str, 

78 name: str, 

79 value: __.typx.Any, 

80 ) -> None: raise NotImplementedError 

81 

82 

83class DeleterCore( __.typx.Protocol ): 

84 ''' Core implementation of attributes deleter. ''' 

85 

86 @staticmethod 

87 def __call__( # noqa: PLR0913 # pragma: no branch 

88 obj: object, /, *, 

89 ligation: DeleterLigation, 

90 attributes_namer: AttributesNamer, 

91 error_class_provider: ErrorClassProvider, 

92 level: str, 

93 name: str, 

94 ) -> None: raise NotImplementedError 

95 

96 

97class SurveyorCore( __.typx.Protocol ): 

98 ''' Core implementation of attributes surveyor. ''' 

99 

100 @staticmethod 

101 def __call__( # pragma: no branch 

102 obj: object, /, *, 

103 ligation: SurveyorLigation, 

104 attributes_namer: AttributesNamer, 

105 level: str, 

106 ) -> __.cabc.Iterable[ str ]: raise NotImplementedError 

107 

108 

109class ClassPreparer( __.typx.Protocol ): 

110 ''' Prepares class for decorator application. ''' 

111 

112 @staticmethod 

113 def __call__( # pragma: no branch 

114 class_: type, 

115 decorators: DecoratorsMutable[ __.U ], /, *, 

116 attributes_namer: AttributesNamer, 

117 ) -> None: raise NotImplementedError 

118 

119 

120DynadocConfiguration: __.typx.TypeAlias = __.cabc.Mapping[ str, __.typx.Any ] 

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

122 __.ddoc.Context, 

123 __.ddoc.Doc( 

124 ''' Dynadoc context. 

125 

126 Renderer, dictionaries for resolution of stringified annotations, 

127 etc.... 

128 ''' ), 

129] 

130DynadocIntrospectionArgument: __.typx.TypeAlias = __.typx.Annotated[ 

131 __.ddoc.IntrospectionControl, 

132 __.ddoc.Doc( 

133 ''' Dynadoc introspection control. 

134 

135 Which kinds of object to recursively introspect? 

136 Scan unnannotated attributes? 

137 Consider base classes? 

138 Etc... 

139 ''' ), 

140] 

141DynadocPreserveArgument: __.typx.TypeAlias = __.typx.Annotated[ 

142 bool, __.ddoc.Doc( ''' Preserve existing docstring? ''' ) 

143] 

144DynadocTableArgument: __.typx.TypeAlias = __.typx.Annotated[ 

145 __.cabc.Mapping[ str, str ], 

146 __.ddoc.Doc( ''' Table of documentation fragments. ''' ), 

147] 

148ProduceDynadocConfigurationReturn: __.typx.TypeAlias = __.typx.Annotated[ 

149 DynadocConfiguration, 

150 __.ddoc.Doc( 

151 ''' Dynadoc configuration dictionary. 

152 

153 Suitable as a keyword expansion (``**``) argument to 

154 ``assign_module_docstring`` or ``with_docstring``. 

155 ''' ), 

156]