|
17 | 17 | from .aslist import aslist
|
18 | 18 | import rdflib
|
19 | 19 | from rdflib.namespace import RDF, RDFS, OWL
|
| 20 | +from rdflib.plugins.parsers.notation3 import BadSyntax |
20 | 21 | import xml.sax
|
21 | 22 | from typing import cast, Union, Tuple, Dict, Any, Callable, Iterable
|
22 | 23 |
|
@@ -160,6 +161,10 @@ def add_schemas(self, ns, base_url):
|
160 | 161 | break
|
161 | 162 | except xml.sax.SAXParseException: # type: ignore
|
162 | 163 | pass
|
| 164 | + except TypeError: |
| 165 | + pass |
| 166 | + except BadSyntax: |
| 167 | + pass |
163 | 168 |
|
164 | 169 | for s, _, _ in self.graph.triples((None, RDF.type, RDF.Property)):
|
165 | 170 | self._add_properties(s)
|
@@ -268,9 +273,7 @@ def resolve_ref(self, ref, base_url=None):
|
268 | 273 | if not isinstance(ref, (str, unicode)):
|
269 | 274 | raise ValueError("Must be string: `%s`" % str(ref))
|
270 | 275 |
|
271 |
| - url = self.expand_url(cast( # bug in mypy 0.3.1, fixed in 0.4-dev |
272 |
| - Union[str, unicode], ref), base_url, |
273 |
| - scoped=(obj is not None)) |
| 276 | + url = self.expand_url(ref, base_url, scoped=(obj is not None)) |
274 | 277 |
|
275 | 278 | # Has this reference been loaded already?
|
276 | 279 | if url in self.idx:
|
@@ -316,7 +319,7 @@ def resolve_ref(self, ref, base_url=None):
|
316 | 319 | return obj, metadata
|
317 | 320 |
|
318 | 321 | def resolve_all(self, document, base_url, file_base=None):
|
319 |
| - # type: (Any, Union[str, unicode], Union[str, unicode]) -> Tuple[Any, Dict[str, str]] |
| 322 | + # type: (Any, Union[str, unicode], Union[str, unicode]) -> Tuple[Any, Dict[str, Any]] |
320 | 323 | loader = self
|
321 | 324 | metadata = {} # type: Dict[str, Any]
|
322 | 325 | if file_base is None:
|
@@ -526,13 +529,11 @@ def validate_link(self, field, link):
|
526 | 529 | if isinstance(link, (str, unicode)):
|
527 | 530 | if field in self.vocab_fields:
|
528 | 531 | if link not in self.vocab and link not in self.idx and link not in self.rvocab:
|
529 |
| - if not self.check_file(cast( # bug in mypy 0.3.1 |
530 |
| - Union[str, unicode], link)): # fixed in mypy 0.4-dev |
| 532 | + if not self.check_file(link): |
531 | 533 | raise validate.ValidationException(
|
532 | 534 | "Field `%s` contains undefined reference to `%s`" % (field, link))
|
533 | 535 | elif link not in self.idx and link not in self.rvocab:
|
534 |
| - if not self.check_file(cast( # bug in mypy 0.3.1 |
535 |
| - Union[str, unicode], link)): # fixed in mypy 0.4-dev |
| 536 | + if not self.check_file(link): |
536 | 537 | raise validate.ValidationException(
|
537 | 538 | "Field `%s` contains undefined reference to `%s`" % (field, link))
|
538 | 539 | elif isinstance(link, list):
|
|
0 commit comments