@@ -30,20 +30,20 @@ def _add_namespaces(graph: Graph, context: dict[str, Any]) -> None:
3030 graph .bind ("rdf" , Namespace ("http://www.w3.org/1999/02/22-rdf-syntax-ns#" ))
3131
3232
33- def _expand_curie (curie : str ) -> str : # pragma: no cover
33+ def _expand_curie (curie : str ) -> str :
3434 if ":" not in curie :
35- return curie
35+ return curie # pragma: no cover
3636 ctx = _linked_art_context .get ("@context" , {})
3737 prefix , local = curie .split (":" , 1 )
3838 base = ctx .get (prefix )
3939 if isinstance (base , str ):
4040 return base + local
41- return curie
41+ return curie # pragma: no cover
4242
4343
4444def _resolve_predicate (
4545 key : str ,
46- data_type : str | None = None ) -> URIRef | None : # pragma: no cover
46+ data_type : str | None = None ) -> URIRef | None :
4747 ctx = _linked_art_context .get ("@context" , {})
4848
4949 if data_type and data_type in ctx :
@@ -54,16 +54,15 @@ def _resolve_predicate(
5454 entry = tctx [key ]
5555 if isinstance (entry , dict ) and "@id" in entry :
5656 return URIRef (_expand_curie (entry ["@id" ]))
57- if isinstance (entry , str ):
57+ if isinstance (entry , str ): # pragma: no cover
5858 return URIRef (_expand_curie (entry ))
5959
6060 entry = ctx .get (key )
6161 if isinstance (entry , dict ) and "@id" in entry :
6262 return URIRef (_expand_curie (entry ["@id" ]))
63- if isinstance (entry , str ):
63+ if isinstance (entry , str ): # pragma: no cover
6464 return URIRef (_expand_curie (entry ))
65-
66- return None
65+ return None # pragma: no cover
6766
6867
6968def _get_subject (
@@ -106,41 +105,36 @@ def _add_triples_from_linked_art(
106105 graph : Graph ,
107106 data : list [dict [str , Any ]] | dict [str , Any ],
108107 parent_subject : URIRef | BNode | None = None ,
109- parent_predicate : URIRef | None = None ) -> None : # pragma: no cover
110- if not isinstance (data , dict ): # pragma: no cover - mypy
111- return
108+ parent_predicate : URIRef | None = None ) -> None :
109+ if not isinstance (data , dict ):
110+ return # pragma: no cover
112111
113112 subject = _get_subject (data , graph , parent_subject , parent_predicate )
114-
115- data_type = data .get ("type" )
116- if data_type :
113+ if data_type := data .get ("type" ):
117114 ctx = _linked_art_context .get ("@context" , {})
118115 type_uri : str | None = None
119116
120117 if ":" in data_type :
121- type_uri = _expand_curie (data_type )
122-
118+ type_uri = _expand_curie (data_type ) # pragma: no cover
123119 elif isinstance (ctx .get (data_type ), dict ):
124120 entry = ctx [data_type ]
125121 if "@id" in entry :
126122 type_uri = _expand_curie (entry ["@id" ])
127123
128- if not type_uri :
124+ if not type_uri : # pragma: no cover
129125 la_base = ctx .get ("la" ) or "https://linked.art/ns/terms/"
130126 type_uri = la_base + data_type
131127
132- if not type_uri : # pragma: no cover - mypy
133- return
128+ if not type_uri :
129+ return # pragma: no cover
134130
135131 graph .add ((subject , RDF .type , URIRef (type_uri )))
136132
137133 for key , value in data .items ():
138134 if key in {"id" , "type" , "@context" }:
139135 continue
140-
141- predicate = _resolve_predicate (key , data_type )
142- if not predicate : # pragma: no cover - mypy
143- continue
136+ if not (predicate := _resolve_predicate (key , data_type )):
137+ continue # pragma: no cover
144138
145139 _handle_value (graph , subject , predicate , value )
146140
0 commit comments