Coverage for sources/accretive/__/nomina.py: 100%

22 statements  

« prev     ^ index     » next       coverage.py v7.10.7, created at 2025-09-26 03: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''' Common names and type aliases. ''' 

22 

23# ruff: noqa: F401 

24 

25 

26from . import imports as __ 

27 

28 

29from classcore.standard.nomina import ( # isort: skip 

30 AssignerLigation, 

31 AttributesNamer, 

32 BehaviorExclusionNamesOmni, 

33 BehaviorExclusionRegexes, 

34 BehaviorExclusionPredicates, 

35 BehaviorExclusionVerifiersOmni, 

36 DecorationPreparers as ClassDecorationPreparers, 

37 DynadocConfiguration, 

38 ErrorClassProvider, 

39 concealment_label, 

40 immutability_label, 

41) 

42 

43 

44H = __.typx.TypeVar( 'H', bound = __.cabc.Hashable ) # Hash Key 

45T = __.typx.TypeVar( 'T', bound = type ) # Class 

46U = __.typx.TypeVar( 'U' ) # Class 

47V = __.typx.TypeVar( 'V' ) # Value 

48 

49 

50ComparisonResult: __.typx.TypeAlias = bool | __.types.NotImplementedType 

51NominativeArguments: __.typx.TypeAlias = __.cabc.Mapping[ str, __.typx.Any ] 

52PositionalArguments: __.typx.TypeAlias = __.cabc.Sequence[ __.typx.Any ] 

53 

54# TODO: Import ClassDecorator aliases from 'classcore' once documentation 

55# fragments have been removed from them. 

56ClassDecorator: __.typx.TypeAlias = ( 

57 __.cabc.Callable[ [ type[ U ] ], type[ U ] ] ) 

58ClassDecorators: __.typx.TypeAlias = ( 

59 __.cabc.Sequence[ ClassDecorator[ U ] ] ) 

60ClassDecoratorFactory: __.typx.TypeAlias = ( 

61 __.cabc.Callable[ ..., ClassDecorator[ U ] ] ) 

62ModuleReclassifier: __.typx.TypeAlias = __.cabc.Callable[ 

63 [ __.cabc.Mapping[ str, __.typx.Any ] ], None ] 

64 

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

66 V, 

67 __.ddoc.Doc( 

68 'Zero or more keyword arguments from which to initialize ' 

69 'dictionary data.' ), 

70] 

71DictionaryPositionalArgument: __.typx.TypeAlias = __.typx.Annotated[ 

72 __.cabc.Mapping[ H, V ] | __.cabc.Iterable[ tuple[ H, V ] ], 

73 __.ddoc.Doc( 

74 'Zero or more iterables from which to initialize dictionary data. ' 

75 'Each iterable must be dictionary or sequence of key-value pairs. ' 

76 'Duplicate keys will result in an error.' ), 

77] 

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

79 __.cabc.Callable[ [ ], V ], 

80 __.ddoc.Doc( 

81 'Callable which produces values for absent dictionary entries.' ), 

82] 

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

84 __.cabc.Callable[ [ H, V ], bool ], 

85 __.ddoc.Doc( 

86 'Callable which validates entries before addition to dictionary.' ), 

87] 

88 

89 

90package_name = __name__.split( '.', maxsplit = 1 )[ 0 ] 

91 

92 

93def calculate_attrname( level: str, core: str ) -> str: 

94 return f"_{package_name}_{level}_{core}_" 

95 

96 

97# TODO: Import 'is_public_identifier' from 'classcore'. 

98def is_public_identifier( name: str ) -> bool: 

99 ''' Is Python identifier public? ''' 

100 return not name.startswith( '_' )