Skip to content

Commit f0ac285

Browse files
author
Peter Amstutz
committed
Merge branch 'master' of github.com:common-workflow-language/schema_salad
# Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
2 parents 8c5bda0 + 84738f1 commit f0ac285

File tree

8 files changed

+51
-30
lines changed

8 files changed

+51
-30
lines changed

Makefile

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pep8: $(PYSOURCES)
6565
pep8 --exclude=_version.py --show-source --show-pep8 $^ || true
6666

6767
pep8_report.txt: $(PYSOURCES)
68-
pep8 --exclude=_version.py $^ > pep8_report.txt || true
68+
pep8 --exclude=_version.py $^ > $@ || true
6969

7070
diff_pep8_report: pep8_report.txt
7171
diff-quality --violations=pep8 pep8_report.txt
@@ -75,7 +75,7 @@ pep257: $(PYSOURCES)
7575
pep257 --ignore=D100,D101,D102,D103 $^ || true
7676

7777
pep257_report.txt: $(PYSOURCES)
78-
pep257 setup.py $^ > pep257_report.txt 2>&1 || true
78+
pep257 setup.py $^ > $@ 2>&1 || true
7979

8080
diff_pep257_report: pep257_report.txt
8181
diff-quality --violations=pep8 pep257_report.txt
@@ -96,7 +96,7 @@ pylint: $(PYSOURCES)
9696

9797
pylint_report.txt: ${PYSOURCES}
9898
pylint --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \
99-
$^ > pylint_report.txt || true
99+
$^ > $@ || true
100100

101101
diff_pylint_report: pylint_report.txt
102102
diff-quality --violations=pylint pylint_report.txt
@@ -147,19 +147,18 @@ htmlcov/index.html: .coverage
147147
coverage-report: .coverage
148148
coverage report
149149

150-
diff-cover: coverage-gcovr.xml coverage.xml
151-
diff-cover coverage-gcovr.xml coverage.xml
150+
diff-cover: coverage.xml
151+
diff-cover $^
152152

153-
diff-cover.html: coverage-gcovr.xml coverage.xml
154-
diff-cover coverage-gcovr.xml coverage.xml \
155-
--html-report diff-cover.html
153+
diff-cover.html: coverage.xml
154+
diff-cover $^ --html-report $@
156155

157156
## test : run the ${MODULE} test suite
158157
test: FORCE
159-
python tests/test_examples.py
158+
python setup.py test
160159

161160
sloccount.sc: ${PYSOURCES} Makefile
162-
sloccount --duplicates --wide --details $^ > sloccount.sc
161+
sloccount --duplicates --wide --details $^ > $@
163162

164163
## sloccount : count lines of code
165164
sloccount: ${PYSOURCES} Makefile
@@ -170,13 +169,15 @@ list-author-emails:
170169
@git log --format='%aN,%aE' | sort -u | grep -v 'root'
171170

172171
mypy: ${PYSOURCES}
173-
MYPYPATH=typeshed/2.7 mypy --py2 schema_salad
174-
#MYPYPATH=typeshed/2.7 mypy --py2 --disallow-untyped-calls schema_salad
172+
MYPYPATH=typeshed/2.7 mypy --py2 --disallow-untyped-calls schema_salad
175173

176174
jenkins:
177175
if ! test -d env ; then virtualenv env ; fi
178176
. env/bin/activate ; \
179-
${MAKE} install-dep coverage.html coverage.xml mypy pep257_report.txt \
177+
${MAKE} install-dep coverage.html coverage.xml pep257_report.txt \
180178
sloccount.sc pep8_report.txt pylint_report.txt
179+
if ! test -d env3 ; then virtualenv -p python3 env3 ; fi
180+
. env3/bin/activate ; \
181+
pip install mypy-lang; ${MAKE} mypy
181182

182183
FORCE:

schema_salad/ref_resolver.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from .aslist import aslist
1818
import rdflib
1919
from rdflib.namespace import RDF, RDFS, OWL
20+
from rdflib.plugins.parsers.notation3 import BadSyntax
2021
import xml.sax
2122
from typing import cast, Union, Tuple, Dict, Any, Callable, Iterable
2223

@@ -160,6 +161,10 @@ def add_schemas(self, ns, base_url):
160161
break
161162
except xml.sax.SAXParseException: # type: ignore
162163
pass
164+
except TypeError:
165+
pass
166+
except BadSyntax:
167+
pass
163168

164169
for s, _, _ in self.graph.triples((None, RDF.type, RDF.Property)):
165170
self._add_properties(s)
@@ -268,9 +273,7 @@ def resolve_ref(self, ref, base_url=None):
268273
if not isinstance(ref, (str, unicode)):
269274
raise ValueError("Must be string: `%s`" % str(ref))
270275

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))
274277

275278
# Has this reference been loaded already?
276279
if url in self.idx:
@@ -316,7 +319,7 @@ def resolve_ref(self, ref, base_url=None):
316319
return obj, metadata
317320

318321
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]]
320323
loader = self
321324
metadata = {} # type: Dict[str, Any]
322325
if file_base is None:
@@ -526,13 +529,11 @@ def validate_link(self, field, link):
526529
if isinstance(link, (str, unicode)):
527530
if field in self.vocab_fields:
528531
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):
531533
raise validate.ValidationException(
532534
"Field `%s` contains undefined reference to `%s`" % (field, link))
533535
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):
536537
raise validate.ValidationException(
537538
"Field `%s` contains undefined reference to `%s`" % (field, link))
538539
elif isinstance(link, list):

schema_salad/schema.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def get_metaschema():
159159

160160

161161
def load_schema(schema_ref, cache=None):
162-
# type: (Union[unicode, Dict[str, Any]], Dict) -> Tuple[ref_resolver.Loader, Union[avro.schema.Names, avro.schema.SchemaParseException], Dict[unicode, Any]]
162+
# type: (Union[unicode, Dict[str, Any]], Dict) -> Tuple[ref_resolver.Loader, Union[avro.schema.Names, avro.schema.SchemaParseException], Dict[unicode, Any], ref_resolver.Loader]
163163
metaschema_names, metaschema_doc, metaschema_loader = get_metaschema()
164164
if cache is not None:
165165
metaschema_loader.cache = cache
@@ -330,12 +330,8 @@ def make_valid_avro(items, alltypes, found, union=False):
330330
ret.append(make_valid_avro(i, alltypes, found, union=union))
331331
return ret
332332
if union and isinstance(items, (str, unicode)):
333-
if items in alltypes and avro_name(cast( # bug in mypy 0.3.1, fixed in
334-
Union[str, unicode], items)) not in found: # 0.4-dev
335-
return cast(Dict,
336-
make_valid_avro(alltypes[cast( # bug in mypy 0.3.1, fixed
337-
# fixed in 0.4-dev
338-
Union[str, unicode], items)], alltypes, found,
333+
if items in alltypes and avro_name(items) not in found:
334+
return cast(Dict, make_valid_avro(alltypes[items], alltypes, found,
339335
union=union))
340336
items = avro_name(items) # type: ignore
341337
# bug in mypy 0.3.1, fixed in 0.4-dev

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ deps = -rrequirements.txt
99
[testenv:py34-mypy]
1010
commands = make mypy
1111
whitelist_externals = make
12-
deps = mypy-lang
12+
deps = mypy-lang>=0.4
1313

1414
[testenv:py35-lint]
1515
commands = flake8 schema_salad setup.py

typeshed/2.7/rdflib/graph.pyi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ class Graph(Node):
7070
def namespaces(self): ...
7171
def absolutize(self, uri, defrag=1): ...
7272
def serialize(self, destination: Union[str, IO[Any]]=None, format: str='', base: str=None, encoding: str=None, **args) -> Union[bytes, None]: ...
73-
def parse(self, source: str=None, publicID: str=None, format: str=None, location: str=None, file: IO[Any]=None, data: str=None, **args): ...
73+
def parse(self, source: str = None, publicID: str = None,
74+
format: Union[str, unicode] = None,
75+
location: Union[str, unicode] = None, file: IO[Any] = None,
76+
data: str = None, **args): ...
7477
def load(self, source, publicID=None, format=''): ...
7578
def query(self, query_object, processor: str = '', result: str = '', initNs: Dict = None, initBindings: Dict = None, use_store_provided: bool = True, **kwargs) -> Result: ...
7679
def update(self, update_object, processor='', initNs=..., initBindings=..., use_store_provided=True, **kwargs): ...
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Stubs for rdflib.plugins (Python 3.5)
2+
#
3+
# NOTE: This dynamically typed stub was automatically generated by stubgen.
4+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Stubs for rdflib.plugins.parsers (Python 3.5)
2+
#
3+
# NOTE: This dynamically typed stub was automatically generated by stubgen.
4+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Stubs for rdflib.plugins.parsers.notation3 (Python 3.5)
2+
#
3+
# NOTE: This dynamically typed stub was automatically generated by stubgen.
4+
5+
from typing import Any
6+
from rdflib.parser import Parser
7+
8+
class BadSyntax(SyntaxError):
9+
lines = ... # type: Any
10+
def __init__(self, uri, lines, argstr, i, why): ...
11+
@property
12+
def message(self): ...

0 commit comments

Comments
 (0)