36
36
ENUM_NAME = Union [EnumDefinitionName , str ]
37
37
38
38
ElementType = TypeVar ("ElementType" , bound = Element )
39
- ElementNameType = TypeVar ("ElementNameType" , bound = Union [ElementName ,str ])
39
+ ElementNameType = TypeVar ("ElementNameType" , bound = Union [ElementName , str ])
40
40
DefinitionType = TypeVar ("DefinitionType" , bound = Definition )
41
- DefinitionNameType = TypeVar ("DefinitionNameType" , bound = Union [DefinitionName ,str ])
41
+ DefinitionNameType = TypeVar ("DefinitionNameType" , bound = Union [DefinitionName , str ])
42
42
ElementDict = Dict [ElementNameType , ElementType ]
43
43
DefDict = Dict [DefinitionNameType , DefinitionType ]
44
44
@@ -53,7 +53,6 @@ class OrderedBy(Enum):
53
53
"""
54
54
55
55
56
-
57
56
def _closure (f , x , reflexive = True , depth_first = True , ** kwargs ):
58
57
if reflexive :
59
58
rv = [x ]
@@ -84,7 +83,7 @@ def load_schema_wrap(path: str, **kwargs):
84
83
schema : SchemaDefinition
85
84
schema = yaml_loader .load (path , target_class = SchemaDefinition , ** kwargs )
86
85
if "\n " not in path :
87
- # if "\n" not in path and "://" not in path:
86
+ # if "\n" not in path and "://" not in path:
88
87
# only set path if the input is not a yaml string or URL.
89
88
# Setting the source path is necessary for relative imports;
90
89
# while initializing a schema with a yaml string is possible, there
@@ -229,7 +228,8 @@ def load_import(self, imp: str, from_schema: SchemaDefinition = None):
229
228
return schema
230
229
231
230
@lru_cache (None )
232
- def imports_closure (self , imports : bool = True , traverse : Optional [bool ] = None , inject_metadata = True ) -> List [SchemaDefinitionName ]:
231
+ def imports_closure (self , imports : bool = True , traverse : Optional [bool ] = None , inject_metadata = True ) -> List [
232
+ SchemaDefinitionName ]:
233
233
"""
234
234
Return all imports
235
235
@@ -314,7 +314,7 @@ def imports_closure(self, imports: bool = True, traverse: Optional[bool] = None,
314
314
visited .add (sn )
315
315
316
316
# filter duplicates, keeping first entry
317
- closure = list ({k :None for k in closure }.keys ())
317
+ closure = list ({k : None for k in closure }.keys ())
318
318
319
319
if inject_metadata :
320
320
for s in self .schema_map .values ():
@@ -420,7 +420,6 @@ def _order_inheritance(self, elements: DefDict) -> DefDict:
420
420
421
421
return {s .name : s for s in slist }
422
422
423
-
424
423
@lru_cache (None )
425
424
def all_classes (self , ordered_by = OrderedBy .PRESERVE , imports = True ) -> Dict [ClassDefinitionName , ClassDefinition ]:
426
425
"""
@@ -865,15 +864,14 @@ def permissible_value_ancestors(self, permissible_value_text: str,
865
864
866
865
@lru_cache (None )
867
866
def permissible_value_descendants (self , permissible_value_text : str ,
868
- enum_name : ENUM_NAME ,
869
- reflexive = True ,
870
- depth_first = True ) -> List [str ]:
867
+ enum_name : ENUM_NAME ,
868
+ reflexive = True ,
869
+ depth_first = True ) -> List [str ]:
871
870
"""
872
871
Closure of permissible_value_children method
873
872
:enum
874
873
"""
875
874
876
-
877
875
return _closure (lambda x : self .permissible_value_children (x , enum_name ),
878
876
permissible_value_text ,
879
877
reflexive = reflexive ,
@@ -1396,9 +1394,9 @@ def induced_slot(self, slot_name: SLOT_NAME, class_name: CLASS_NAME = None, impo
1396
1394
else :
1397
1395
# can rewrite below as:
1398
1396
# 1. if v2:
1399
- # 2. if v2 is not None and
1397
+ # 2. if v2 is not None and
1400
1398
# (
1401
- # (isinstance(v2, (dict, list)) and v2) or
1399
+ # (isinstance(v2, (dict, list)) and v2) or
1402
1400
# (isinstance(v2, JsonObj) and as_dict(v2))
1403
1401
# )
1404
1402
if not is_empty (v2 ):
@@ -1548,7 +1546,7 @@ def is_inlined(self, slot: SlotDefinition, imports=True) -> bool:
1548
1546
return True
1549
1547
elif slot .inlined_as_list :
1550
1548
return True
1551
-
1549
+
1552
1550
id_slot = self .get_identifier_slot (range , imports = imports )
1553
1551
if id_slot is None :
1554
1552
# must be inlined as has no identifier
@@ -1592,7 +1590,7 @@ def slot_range_as_union(self, slot: SlotDefinition) -> List[ElementName]:
1592
1590
"""
1593
1591
Returns all applicable ranges for a slot
1594
1592
1595
- Typically any given slot has exactly one range, and one metamodel element type,
1593
+ Typically, any given slot has exactly one range, and one metamodel element type,
1596
1594
but a proposed feature in LinkML 1.2 is range expressions, where ranges can be defined as unions
1597
1595
1598
1596
:param slot:
@@ -1604,9 +1602,9 @@ def slot_range_as_union(self, slot: SlotDefinition) -> List[ElementName]:
1604
1602
if x .range :
1605
1603
range_union_of .append (x .range )
1606
1604
return range_union_of
1607
-
1605
+
1608
1606
def get_classes_by_slot (
1609
- self , slot : SlotDefinition , include_induced : bool = False
1607
+ self , slot : SlotDefinition , include_induced : bool = False
1610
1608
) -> List [ClassDefinitionName ]:
1611
1609
"""Get all classes that use a given slot, either as a direct or induced slot.
1612
1610
0 commit comments