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

32 statements  

« prev     ^ index     » next       coverage.py v7.10.7, created at 2025-09-25 13:22 +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[ '*' ] ) 

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

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

50 __.ddoc.Doc( 

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

52 

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

54 own hierarchies rather than the hierarchy from this package. 

55 ''' ), 

56] 

57 

58 

59class AssignerCore( __.typx.Protocol ): 

60 ''' Core implementation of attributes assigner. ''' 

61 

62 @staticmethod 

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

64 obj: object, /, *, 

65 ligation: AssignerLigation, 

66 attributes_namer: AttributesNamer, 

67 error_class_provider: ErrorClassProvider, 

68 level: str, 

69 name: str, 

70 value: __.typx.Any, 

71 ) -> None: raise NotImplementedError 

72 

73 

74class DeleterCore( __.typx.Protocol ): 

75 ''' Core implementation of attributes deleter. ''' 

76 

77 @staticmethod 

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

79 obj: object, /, *, 

80 ligation: DeleterLigation, 

81 attributes_namer: AttributesNamer, 

82 error_class_provider: ErrorClassProvider, 

83 level: str, 

84 name: str, 

85 ) -> None: raise NotImplementedError 

86 

87 

88class SurveyorCore( __.typx.Protocol ): 

89 ''' Core implementation of attributes surveyor. ''' 

90 

91 @staticmethod 

92 def __call__( # pragma: no branch 

93 obj: object, /, *, 

94 ligation: SurveyorLigation, 

95 attributes_namer: AttributesNamer, 

96 level: str, 

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

98 

99 

100class ClassPreparer( __.typx.Protocol ): 

101 ''' Prepares class for decorator application. ''' 

102 

103 @staticmethod 

104 def __call__( # pragma: no branch 

105 class_: type, 

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

107 attributes_namer: AttributesNamer, 

108 ) -> None: raise NotImplementedError 

109 

110 

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

112# TODO: Use argument type aliases from 'dynadoc' package. 

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

114 __.ddoc.Context, 

115 __.ddoc.Doc( 

116 ''' Dynadoc context. 

117 

118 Renderer, dictionaries for resolution of stringified annotations, 

119 etc.... 

120 ''' ), 

121] 

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

123 __.ddoc.IntrospectionControl, 

124 __.ddoc.Doc( 

125 ''' Dynadoc introspection control. 

126 

127 Which kinds of object to recursively introspect? 

128 Scan unnannotated attributes? 

129 Consider base classes? 

130 Etc... 

131 ''' ), 

132] 

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

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

135] 

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

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

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

139] 

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

141 DynadocConfiguration, 

142 __.ddoc.Doc( 

143 ''' Dynadoc configuration dictionary. 

144 

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

146 ``assign_module_docstring`` or ``with_docstring``. 

147 ''' ), 

148]