Skip to content

Commit 965cf8e

Browse files
add no repr to enum parent class, and to tested metaclasses
1 parent 42a3bb4 commit 965cf8e

File tree

3 files changed

+36
-36
lines changed

3 files changed

+36
-36
lines changed

linkml_runtime/linkml_model/meta.py

+34-34
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class UniqueKeyUniqueKeyName(extended_str):
144144

145145
Anything = Any
146146

147-
@dataclass
147+
@dataclass(repr=False)
148148
class CommonMetadata(YAMLRoot):
149149
"""
150150
Generic metadata shared across definitions
@@ -307,7 +307,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
307307
super().__post_init__(**kwargs)
308308

309309

310-
@dataclass
310+
@dataclass(repr=False)
311311
class Element(YAMLRoot):
312312
"""
313313
A named element in the model
@@ -512,7 +512,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
512512
super().__post_init__(**kwargs)
513513

514514

515-
@dataclass
515+
@dataclass(repr=False)
516516
class SchemaDefinition(Element):
517517
"""
518518
A collection of definitions that make up a schema or a data model.
@@ -619,7 +619,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
619619
super().__post_init__(**kwargs)
620620

621621

622-
@dataclass
622+
@dataclass(repr=False)
623623
class AnonymousTypeExpression(YAMLRoot):
624624
"""
625625
A type expression that is not a top-level named type definition. Used for nesting.
@@ -687,7 +687,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
687687
super().__post_init__(**kwargs)
688688

689689

690-
@dataclass
690+
@dataclass(repr=False)
691691
class TypeDefinition(Element):
692692
"""
693693
an element that whose instances are atomic scalar values that can be mapped to primitive types
@@ -782,7 +782,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
782782
super().__post_init__(**kwargs)
783783

784784

785-
@dataclass
785+
@dataclass(repr=False)
786786
class SubsetDefinition(Element):
787787
"""
788788
an element that can be used to group other metamodel elements
@@ -805,7 +805,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
805805
super().__post_init__(**kwargs)
806806

807807

808-
@dataclass
808+
@dataclass(repr=False)
809809
class Definition(Element):
810810
"""
811811
abstract base class for core metaclasses
@@ -854,7 +854,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
854854
super().__post_init__(**kwargs)
855855

856856

857-
@dataclass
857+
@dataclass(repr=False)
858858
class AnonymousEnumExpression(YAMLRoot):
859859
"""
860860
An enum_expression that is not named
@@ -918,7 +918,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
918918
super().__post_init__(**kwargs)
919919

920920

921-
@dataclass
921+
@dataclass(repr=False)
922922
class EnumDefinition(Definition):
923923
"""
924924
an element whose instances must be drawn from a specified set of permissible values
@@ -992,7 +992,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
992992
super().__post_init__(**kwargs)
993993

994994

995-
@dataclass
995+
@dataclass(repr=False)
996996
class MatchQuery(YAMLRoot):
997997
"""
998998
A query that is used on an enum expression to dynamically obtain a set of permissivle values via a query that
@@ -1018,7 +1018,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
10181018
super().__post_init__(**kwargs)
10191019

10201020

1021-
@dataclass
1021+
@dataclass(repr=False)
10221022
class ReachabilityQuery(YAMLRoot):
10231023
"""
10241024
A query that is used on an enum expression to dynamically obtain a set of permissible values via walking from a
@@ -1062,7 +1062,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
10621062
super().__post_init__(**kwargs)
10631063

10641064

1065-
@dataclass
1065+
@dataclass(repr=False)
10661066
class StructuredAlias(YAMLRoot):
10671067
"""
10681068
object that contains meta data about a synonym or alias including where it came from (source) and its scope
@@ -1254,7 +1254,7 @@ class Expression(YAMLRoot):
12541254
class_model_uri: ClassVar[URIRef] = LINKML.Expression
12551255

12561256

1257-
@dataclass
1257+
@dataclass(repr=False)
12581258
class TypeExpression(Expression):
12591259
"""
12601260
An abstract class grouping named types and anonymous type expressions
@@ -1322,7 +1322,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
13221322
super().__post_init__(**kwargs)
13231323

13241324

1325-
@dataclass
1325+
@dataclass(repr=False)
13261326
class EnumExpression(Expression):
13271327
"""
13281328
An expression that constrains the range of a slot
@@ -1386,7 +1386,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
13861386
super().__post_init__(**kwargs)
13871387

13881388

1389-
@dataclass
1389+
@dataclass(repr=False)
13901390
class AnonymousExpression(YAMLRoot):
13911391
"""
13921392
An abstract parent class for any nested expression
@@ -1555,7 +1555,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
15551555
super().__post_init__(**kwargs)
15561556

15571557

1558-
@dataclass
1558+
@dataclass(repr=False)
15591559
class PathExpression(YAMLRoot):
15601560
"""
15611561
An expression that describes an abstract path from an object to another through a sequence of slot lookups
@@ -1760,7 +1760,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
17601760
super().__post_init__(**kwargs)
17611761

17621762

1763-
@dataclass
1763+
@dataclass(repr=False)
17641764
class SlotExpression(Expression):
17651765
"""
17661766
an expression that constrains the range of values a slot can take
@@ -1884,7 +1884,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
18841884
super().__post_init__(**kwargs)
18851885

18861886

1887-
@dataclass
1887+
@dataclass(repr=False)
18881888
class AnonymousSlotExpression(AnonymousExpression):
18891889
_inherited_slots: ClassVar[List[str]] = ["range", "required", "recommended", "inlined", "inlined_as_list", "minimum_value", "maximum_value", "pattern", "structured_pattern", "value_presence", "equals_string", "equals_string_in", "equals_number", "equals_expression", "exact_cardinality", "minimum_cardinality", "maximum_cardinality"]
18901890

@@ -2005,7 +2005,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
20052005
super().__post_init__(**kwargs)
20062006

20072007

2008-
@dataclass
2008+
@dataclass(repr=False)
20092009
class SlotDefinition(Definition):
20102010
"""
20112011
an element that describes how instances are related to other instances
@@ -2304,7 +2304,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
23042304
super().__post_init__(**kwargs)
23052305

23062306

2307-
@dataclass
2307+
@dataclass(repr=False)
23082308
class ClassExpression(YAMLRoot):
23092309
"""
23102310
A boolean expression that can be used to dynamically determine membership of a class
@@ -2344,7 +2344,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
23442344
super().__post_init__(**kwargs)
23452345

23462346

2347-
@dataclass
2347+
@dataclass(repr=False)
23482348
class AnonymousClassExpression(AnonymousExpression):
23492349
_inherited_slots: ClassVar[List[str]] = []
23502350

@@ -2385,7 +2385,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
23852385
super().__post_init__(**kwargs)
23862386

23872387

2388-
@dataclass
2388+
@dataclass(repr=False)
23892389
class ClassDefinition(Definition):
23902390
"""
23912391
an element whose instances are complex objects that may have slot-value assignments
@@ -2520,7 +2520,7 @@ class ClassLevelRule(YAMLRoot):
25202520
class_model_uri: ClassVar[URIRef] = LINKML.ClassLevelRule
25212521

25222522

2523-
@dataclass
2523+
@dataclass(repr=False)
25242524
class ClassRule(ClassLevelRule):
25252525
"""
25262526
A rule that applies to instances of a class
@@ -2713,7 +2713,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
27132713
super().__post_init__(**kwargs)
27142714

27152715

2716-
@dataclass
2716+
@dataclass(repr=False)
27172717
class ArrayExpression(YAMLRoot):
27182718
"""
27192719
defines the dimensions of an array
@@ -2900,7 +2900,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
29002900
super().__post_init__(**kwargs)
29012901

29022902

2903-
@dataclass
2903+
@dataclass(repr=False)
29042904
class DimensionExpression(YAMLRoot):
29052905
"""
29062906
defines one of the dimensions of an array
@@ -3085,7 +3085,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
30853085
super().__post_init__(**kwargs)
30863086

30873087

3088-
@dataclass
3088+
@dataclass(repr=False)
30893089
class PatternExpression(YAMLRoot):
30903090
"""
30913091
a regular expression pattern used to evaluate conformance of a string
@@ -3266,7 +3266,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
32663266
super().__post_init__(**kwargs)
32673267

32683268

3269-
@dataclass
3269+
@dataclass(repr=False)
32703270
class ImportExpression(YAMLRoot):
32713271
"""
32723272
an expression describing an import
@@ -3448,7 +3448,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
34483448
super().__post_init__(**kwargs)
34493449

34503450

3451-
@dataclass
3451+
@dataclass(repr=False)
34523452
class Setting(YAMLRoot):
34533453
"""
34543454
assignment of a key to a value
@@ -3477,7 +3477,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
34773477
super().__post_init__(**kwargs)
34783478

34793479

3480-
@dataclass
3480+
@dataclass(repr=False)
34813481
class Prefix(YAMLRoot):
34823482
"""
34833483
prefix URI tuple
@@ -3506,7 +3506,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
35063506
super().__post_init__(**kwargs)
35073507

35083508

3509-
@dataclass
3509+
@dataclass(repr=False)
35103510
class LocalName(YAMLRoot):
35113511
"""
35123512
an attributed label
@@ -3535,7 +3535,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
35353535
super().__post_init__(**kwargs)
35363536

35373537

3538-
@dataclass
3538+
@dataclass(repr=False)
35393539
class Example(YAMLRoot):
35403540
"""
35413541
usage example and description
@@ -3561,7 +3561,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
35613561
super().__post_init__(**kwargs)
35623562

35633563

3564-
@dataclass
3564+
@dataclass(repr=False)
35653565
class AltDescription(YAMLRoot):
35663566
"""
35673567
an attributed description
@@ -3590,7 +3590,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
35903590
super().__post_init__(**kwargs)
35913591

35923592

3593-
@dataclass
3593+
@dataclass(repr=False)
35943594
class PermissibleValue(YAMLRoot):
35953595
"""
35963596
a permissible value, accompanied by intended text and an optional mapping to a concept URI
@@ -3782,7 +3782,7 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
37823782
super().__post_init__(**kwargs)
37833783

37843784

3785-
@dataclass
3785+
@dataclass(repr=False)
37863786
class UniqueKey(YAMLRoot):
37873787
"""
37883788
a collection of slots whose values uniquely identify an instance of a class

linkml_runtime/utils/enumerations.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,4 @@ def __str__(self) -> str:
102102

103103
def __repr__(self) -> str:
104104
rlist = [(f.name, getattr(self._code, f.name)) for f in fields(self._code)]
105-
return '(' + ', '.join([f"{f[0]}={repr(f[1])}" for f in rlist if f[1]]) + ')'
105+
return self.__class__.__name__ + '(' + ', '.join([f"{f[0]}={repr(f[1])}" for f in rlist if f[1]]) + ')'

linkml_runtime/utils/yamlutils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def __repr__(self):
286286
continue
287287
res[key] = val
288288
return self.__class__.__name__ + '(' + pformat(res, indent=2,
289-
compact=True) + ')'
289+
compact=True, sort_dicts=False) + ')'
290290

291291
def __str__(self):
292292
"""Dump everything into a dict, recursively, stringifying it all"""

0 commit comments

Comments
 (0)