Coverage for sources/accretive/__/nomina.py: 100%
22 statements
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-28 21:31 +0000
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-28 21:31 +0000
1# vim: set filetype=python fileencoding=utf-8:
2# -*- coding: utf-8 -*-
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#============================================================================#
21''' Common names and type aliases. '''
23# ruff: noqa: F401
26from . import imports as __
29from classcore.standard.nomina import (
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)
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
50ComparisonResult: __.typx.TypeAlias = bool | __.types.NotImplementedType
51NominativeArguments: __.typx.TypeAlias = __.cabc.Mapping[ str, __.typx.Any ]
52PositionalArguments: __.typx.TypeAlias = __.cabc.Sequence[ __.typx.Any ]
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 ]
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]
90package_name = __name__.split( '.', maxsplit = 1 )[ 0 ]
93def calculate_attrname( level: str, core: str ) -> str:
94 return f"_{package_name}_{level}_{core}_"
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( '_' )