Skip to content

Commit 0ddddfd

Browse files
fixed linting
1 parent 25939ce commit 0ddddfd

File tree

21 files changed

+66
-60
lines changed

21 files changed

+66
-60
lines changed

linkml_runtime/index/object_index.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
import inspect
1313
import logging
14-
from collections.abc import Iterator, Mapping
15-
from typing import Any, Union
14+
from collections.abc import Iterator, MutableMapping
15+
from typing import Any
1616

1717
from linkml_runtime import SchemaView
1818
from linkml_runtime.utils import eval_utils
@@ -56,9 +56,9 @@ def __init__(self, obj: YAMLRoot, schemaview: SchemaView):
5656
self._root_object = obj
5757
self._schemaview = schemaview
5858
self._class_map = schemaview.class_name_mappings()
59-
self._source_object_cache: Mapping[str, Any] = {}
60-
self._proxy_object_cache: Mapping[str, ProxyObject] = {}
61-
self._child_to_parent: Mapping[str, list[tuple[str, str]]] = {}
59+
self._source_object_cache: MutableMapping[str, Any] = {}
60+
self._proxy_object_cache: MutableMapping[str, ProxyObject] = {}
61+
self._child_to_parent: MutableMapping[str, list[tuple[str, str]]] = {}
6262
self._index(obj)
6363

6464
def _index(self, obj: Any, parent_key=None, parent=None):
@@ -70,16 +70,11 @@ def _index(self, obj: Any, parent_key=None, parent=None):
7070
return {k: self._index(v, parent_key, parent) for k, v in obj.items()}
7171
cls_name = type(obj).__name__
7272
if cls_name in self._class_map:
73-
cls = self._class_map[cls_name]
7473
pk_val = self._key(obj)
7574
self._source_object_cache[pk_val] = obj
7675
if pk_val not in self._child_to_parent:
7776
self._child_to_parent[pk_val] = []
7877
self._child_to_parent[pk_val].append((parent_key, parent))
79-
# id_slot = self._schemaview.get_identifier_slot(cls.name)
80-
# if id_slot:
81-
# id_val = getattr(obj, id_slot.name)
82-
# self._source_object_cache[(cls.name, id_val)] = obj
8378
for k, v in vars(obj).items():
8479
self._index(v, k, obj)
8580
else:
@@ -115,7 +110,7 @@ def bless(self, obj: Any) -> "ProxyObject":
115110
else:
116111
return ProxyObject(obj, _db=self)
117112

118-
def _key(self, obj: Any) -> tuple[Union[str, YAMLRoot], str]:
113+
def _key(self, obj: Any) -> tuple[str, str]:
119114
"""
120115
Returns primary key value for this object.
121116

linkml_runtime/loaders/rdf_loader.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Union, TextIO, Optional
1+
import json
2+
from typing import Optional, TextIO, Union
23

34
from hbreader import FileInfo
45
from linkml_runtime.loaders.loader_root import Loader
@@ -85,7 +86,7 @@ def loader(data: Union[str, dict], _: FileInfo) -> Optional[dict]:
8586

8687
# If the input is a graph, convert it to JSON-LD
8788
if isinstance(source, Graph):
88-
source = pyld_jsonld_from_rdflib_graph(source)
89+
source = pyld_jsonld_from_rdflib_graph(source) # noqa: F821 - no idea what this is
8990
jsonld_str = source.serialize(format="json-ld", indent=4)
9091
source = json.loads(jsonld_str)
9192
fmt = "json-ld"

linkml_runtime/loaders/rdflib_loader.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ def from_rdf_graph(
5555
:param schemaview: schema to which graph conforms
5656
:param target_class: class which root nodes should instantiate
5757
:param prefix_map: additional prefix mappings for data objects
58-
:param ignore_unmapped_predicates: if True then a predicate that has no mapping to a slot does not raise an error
58+
:param ignore_unmapped_predicates:
59+
if True then a predicate that has no mapping to a slot does not raise an error
5960
:return: all instances of target class type
6061
"""
6162
namespaces = schemaview.namespaces()
@@ -231,8 +232,7 @@ def _get_id_dict(self, node: VALID_SUBJECT, schemaview: SchemaView, cn: ClassDef
231232
id_slot = schemaview.get_identifier_slot(cn)
232233
if not isinstance(node, BNode):
233234
id_val = self._uri_to_id(node, id_slot, schemaview)
234-
# id_val = schemaview.namespaces().curie_for(node)
235-
if id_val == None:
235+
if id_val is None:
236236
id_val = str(node)
237237
return {id_slot.name: id_val}
238238
else:

linkml_runtime/processing/referencevalidator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ def ensure_simple_dict(
667667
) -> Any:
668668
simple_dict_value_slot = self._slot_as_simple_dict_value_slot(parent_slot)
669669
if not simple_dict_value_slot:
670-
raise AssertionError(f"Should have simple dict slot valie: {parent_slot.name}")
670+
raise AssertionError(f"Should have simple dict slot value: {parent_slot.name}")
671671
normalized_object = input_object
672672
if isinstance(input_object, list):
673673
normalized_object = {v[pk_slot_name]: v for v in input_object}

linkml_runtime/processing/validation_datamodel.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,8 @@ class ConstraintType(EnumDefinitionImpl):
405405
)
406406
MinCountConstraint = PermissibleValue(
407407
text="MinCountConstraint",
408-
description="cardinality constraint where the number of values of the slot must be greater or equal to a specified minimum",
408+
description="cardinality constraint where the number of values of the slot must be greater than "
409+
"or equal to a specified minimum",
409410
meaning=SH.MinCountConstraintComponent,
410411
)
411412
RequiredConstraint = PermissibleValue(
@@ -420,7 +421,8 @@ class ConstraintType(EnumDefinitionImpl):
420421
)
421422
MaxCountConstraint = PermissibleValue(
422423
text="MaxCountConstraint",
423-
description="cardinality constraint where the number of values of the slot must be less than or equal to a specified maximum",
424+
description="cardinality constraint where the number of values of the slot must be less than "
425+
"or equal to a specified maximum",
424426
meaning=SH.MaxCountConstraintComponent,
425427
)
426428
SingleValuedConstraint = PermissibleValue(

linkml_runtime/utils/context_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import json
22
import os
33
from io import TextIOWrapper
4-
from typing import Any, Callable, Optional, Union
4+
from typing import TYPE_CHECKING, Any, Callable, Optional, Union
55

66
import yaml
77
from jsonasobj2 import JsonObj, loads
88

9+
if TYPE_CHECKING:
10+
from linkml_runtime.utils.namespaces import Namespaces
11+
912
CONTEXT_TYPE = Union[str, dict, JsonObj]
1013
CONTEXTS_PARAM_TYPE = Optional[Union[CONTEXT_TYPE, list[CONTEXT_TYPE]]]
1114

linkml_runtime/utils/enumerations.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
from dataclasses import fields
2-
from typing import Optional, Union
2+
from typing import TYPE_CHECKING, Optional, Union
33

44
from linkml_runtime.utils.metamodelcore import Curie
55
from linkml_runtime.utils.yamlutils import YAMLRoot
66

7+
if TYPE_CHECKING:
8+
from linkml_runtime.linkml_model import EnumDefinition, PermissibleValue
9+
710

811
class EnumDefinitionMeta(type):
912
def __init__(cls, *args, **kwargs):

linkml_runtime/utils/eval_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
def eval_conditional(*conds: list[tuple[bool, Any]]) -> Any:
2626
"""
27-
Evaluate a collection of expression,value tuples, returing the first value whose expression is true
27+
Evaluate a collection of expression, value tuples, returning the first value whose expression is true
2828
2929
>>> x= 40
3030
>>> eval_conditional((x < 25, 'low'), (x > 25, 'high'), (True, 'low'))

linkml_runtime/utils/formatutils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def wrapped_annotation(txt: str) -> str:
100100
def shex_results_as_string(rslts) -> str:
101101
"""Pretty print ShEx Evaluation result"""
102102
# TODO: Add this method to ShEx itself
103-
rval = [f"Evalutating: {str(rslts.focus)} against {str(rslts.start)}"]
103+
rval = [f"Evaluating: {str(rslts.focus)} against {str(rslts.start)}"]
104104
if rslts.result:
105105
rval.append("Result: CONFORMS")
106106
else:
@@ -158,7 +158,7 @@ def remove_empty_items(obj: Any, hide_protected_keys: bool = False, inside: bool
158158
obj_list = [
159159
e
160160
for e in [
161-
remove_empty_items(l, hide_protected_keys=hide_protected_keys, inside=True) for l in obj if l != "_root"
161+
remove_empty_items(i, hide_protected_keys=hide_protected_keys, inside=True) for i in obj if i != "_root"
162162
]
163163
if not is_empty(e)
164164
]

linkml_runtime/utils/permissiblevalueimpl.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ class PvFormulaOptions(EnumDefinitionImpl):
130130
description="The permissible values are the set of FHIR coding elements derived from the code set",
131131
)
132132

133-
_defn = EnumDefinition(
134-
name="PvFormulaOptions",
135-
description="The formula used to generate the set of permissible values from the code_set values",
136-
)
133+
# _defn = EnumDefinition(
134+
# name="PvFormulaOptions",
135+
# description="The formula used to generate the set of permissible values from the code_set values",
136+
# )
137137

138138

139139
class PermissibleValueImpl(PermissibleValue):

0 commit comments

Comments
 (0)