Skip to content

Commit f21c833

Browse files
committed
Type fix for _get_converter
1 parent f97edda commit f21c833

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/linkml_reference_validator/plugins/reference_validation_plugin.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -303,17 +303,16 @@ def _get_converter(self) -> Optional[Converter]:
303303
return None
304304
schema = self.schema_view.schema
305305
if schema and schema.prefixes:
306-
# schema.prefixes is a dict of prefix name -> Prefix object
307-
# The Prefix object has a prefix_reference attribute with the URI
308-
prefix_map = {
309-
name: (
310-
prefix.get("prefix_reference")
311-
if isinstance(prefix, dict) and "prefix_reference" in prefix
312-
else str(prefix)
313-
)
314-
for name, prefix in schema.prefixes.items()
315-
}
316-
return Converter.from_prefix_map(prefix_map)
306+
# schema.prefixes is a list of Prefix objects
307+
# Each Prefix object has a prefix_name and prefix_reference attribute
308+
prefix_map: dict[str, str] = {}
309+
for prefix in schema.prefixes:
310+
prefix_name = getattr(prefix, "prefix_name", None)
311+
prefix_reference = getattr(prefix, "prefix_reference", None)
312+
if isinstance(prefix_name, str) and prefix_reference is not None:
313+
prefix_map[prefix_name] = str(prefix_reference)
314+
if prefix_map:
315+
return Converter.from_prefix_map(prefix_map)
317316
return None
318317

319318
# type: ignore

0 commit comments

Comments
 (0)