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

34 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-15 02:08 +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 

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

33BehaviorExclusionNamesOmni: __.typx.TypeAlias = ( 

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

35BehaviorExclusionPredicate: __.typx.TypeAlias = ( 

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

37BehaviorExclusionPredicates: __.typx.TypeAlias = ( 

38 __.cabc.Sequence[ BehaviorExclusionPredicate ] ) 

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

40BehaviorExclusionRegexes: __.typx.TypeAlias = ( 

41 __.cabc.Sequence[ BehaviorExclusionRegex ] ) 

42BehaviorExclusionVerifier: __.typx.TypeAlias = ( 

43 str | BehaviorExclusionRegex | BehaviorExclusionPredicate ) 

44BehaviorExclusionVerifiers: __.typx.TypeAlias = ( 

45 __.cabc.Sequence[ BehaviorExclusionVerifier ] ) 

46BehaviorExclusionVerifiersOmni: __.typx.TypeAlias = ( 

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

48InternalNameDetector: __.typx.TypeAlias = ( 

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

50InternalNameDetectors: __.typx.TypeAlias = ( 

51 __.cabc.Sequence[ InternalNameDetector ] ) 

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

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

54 __.ddoc.Doc( 

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

56 

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

58 own hierarchies rather than the hierarchy from this package. 

59 ''' ), 

60] 

61 

62 

63class AssignerCore( __.typx.Protocol ): 

64 ''' Core implementation of attributes assigner. ''' 

65 

66 @staticmethod 

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

68 obj: object, /, *, 

69 ligation: AssignerLigation, 

70 attributes_namer: AttributesNamer, 

71 error_class_provider: ErrorClassProvider, 

72 level: str, 

73 name: str, 

74 value: __.typx.Any, 

75 ) -> None: raise NotImplementedError 

76 

77 

78class DeleterCore( __.typx.Protocol ): 

79 ''' Core implementation of attributes deleter. ''' 

80 

81 @staticmethod 

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

83 obj: object, /, *, 

84 ligation: DeleterLigation, 

85 attributes_namer: AttributesNamer, 

86 error_class_provider: ErrorClassProvider, 

87 level: str, 

88 name: str, 

89 ) -> None: raise NotImplementedError 

90 

91 

92class SurveyorCore( __.typx.Protocol ): 

93 ''' Core implementation of attributes surveyor. ''' 

94 

95 @staticmethod 

96 def __call__( # pragma: no branch 

97 obj: object, /, *, 

98 ligation: SurveyorLigation, 

99 attributes_namer: AttributesNamer, 

100 level: str, 

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

102 

103 

104class ClassPreparer( __.typx.Protocol ): 

105 ''' Prepares class for decorator application. ''' 

106 

107 @staticmethod 

108 def __call__( # pragma: no branch 

109 class_: type, 

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

111 attributes_namer: AttributesNamer, 

112 ) -> None: raise NotImplementedError 

113 

114 

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

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

117 __.ddoc.Context, 

118 __.ddoc.Doc( 

119 ''' Dynadoc context. 

120 

121 Renderer, dictionaries for resolution of stringified annotations, 

122 etc.... 

123 ''' ), 

124] 

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

126 __.ddoc.IntrospectionControl, 

127 __.ddoc.Doc( 

128 ''' Dynadoc introspection control. 

129 

130 Which kinds of object to recursively introspect? 

131 Scan unnannotated attributes? 

132 Consider base classes? 

133 Etc... 

134 ''' ), 

135] 

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

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

138] 

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

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

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

142] 

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

144 DynadocConfiguration, 

145 __.ddoc.Doc( 

146 ''' Dynadoc configuration dictionary. 

147 

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

149 ``assign_module_docstring`` or ``with_docstring``. 

150 ''' ), 

151]