Coverage for sources/frigid/__/imports.py: 100%

14 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2025-01-24 04:09 +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 imports and type aliases used throughout the package. ''' 

22 

23# pylint: disable=unused-import 

24# ruff: noqa: F401 

25 

26 

27from __future__ import annotations 

28 

29import abc 

30import collections.abc as cabc 

31import types 

32 

33import typing_extensions as typx 

34 

35 

36from absence import Absential, absent, is_absent 

37 

38 

39C = typx.TypeVar( 'C' ) # Class 

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

41V = typx.TypeVar( 'V' ) # Value 

42 

43 

44ComparisonResult: typx.TypeAlias = bool | types.NotImplementedType 

45DictionaryNominativeArgument: typx.TypeAlias = typx.Annotated[ 

46 V, 

47 typx.Doc( 

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

49 'dictionary data.' ), 

50] 

51DictionaryPositionalArgument: typx.TypeAlias = typx.Annotated[ 

52 cabc.Mapping[ H, V ] | cabc.Iterable[ tuple[ H, V ] ], 

53 typx.Doc( 

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

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

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

57] 

58DictionaryValidator: typx.TypeAlias = typx.Annotated[ 

59 cabc.Callable[ [ H, V ], bool ], 

60 typx.Doc( 

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

62] 

63ModuleReclassifier: typx.TypeAlias = cabc.Callable[ 

64 [ cabc.Mapping[ str, typx.Any ] ], None ]