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

27 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-05-01 22:29 +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''' Standard classes and class factories. ''' 

22# TODO? ClassMutable and ProtocolClassMutable 

23# Need inheritance of omnimutability and omnivisibility. 

24 

25 

26from __future__ import annotations 

27 

28from . import __ 

29from . import decorators as _decorators 

30 

31 

32@_decorators.decoration_by( *_decorators.class_factory_decorators ) 

33class Class( type ): pass 

34 

35 

36@_decorators.decoration_by( *_decorators.class_factory_decorators ) 

37@__.typx.dataclass_transform( frozen_default = True, kw_only_default = True ) 

38class Dataclass( type ): pass 

39 

40 

41@_decorators.decoration_by( *_decorators.class_factory_decorators ) 

42@__.typx.dataclass_transform( kw_only_default = True ) 

43class DataclassMutable( type ): pass 

44 

45 

46@_decorators.decoration_by( *_decorators.class_factory_decorators ) 

47class ProtocolClass( type( __.typx.Protocol ) ): pass 

48 

49 

50@_decorators.decoration_by( *_decorators.class_factory_decorators ) 

51@__.typx.dataclass_transform( frozen_default = True, kw_only_default = True ) 

52class ProtocolDataclass( type( __.typx.Protocol ) ): pass 

53 

54 

55@_decorators.decoration_by( *_decorators.class_factory_decorators ) 

56@__.typx.dataclass_transform( kw_only_default = True ) 

57class ProtocolDataclassMutable( type( __.typx.Protocol ) ): pass 

58 

59 

60class Object( metaclass = Class ): pass 

61 

62 

63class ObjectMutable( # pyright: ignore[reportGeneralTypeIssues] 

64 metaclass = Class, 

65 instances_mutables = '*', # pyright: ignore[reportCallIssue] 

66): pass 

67 

68 

69class DataclassObject( metaclass = Dataclass ): pass 

70 

71 

72class DataclassObjectMutable( metaclass = DataclassMutable ): pass 

73 

74 

75class Protocol( __.typx.Protocol, metaclass = ProtocolClass ): pass 

76 

77 

78class ProtocolMutable( # pyright: ignore[reportGeneralTypeIssues] 

79 __.typx.Protocol, 

80 metaclass = ProtocolClass, 

81 instances_mutables = '*', # pyright: ignore[reportCallIssue] 

82): pass 

83 

84 

85class DataclassProtocol( 

86 __.typx.Protocol, metaclass = ProtocolDataclass, 

87): pass 

88 

89 

90class DataclassProtocolMutable( 

91 __.typx.Protocol, metaclass = ProtocolDataclassMutable, 

92): pass