Skip to content

Commit 3b8dc09

Browse files
committed
mypy 0.4 is out (#25)
1 parent 5b969ca commit 3b8dc09

File tree

5 files changed

+14
-20
lines changed

5 files changed

+14
-20
lines changed

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ diff-cover.html: coverage.xml
155155

156156
## test : run the ${MODULE} test suite
157157
test: FORCE
158-
python tests/test_examples.py
158+
python setup.py test
159159

160160
sloccount.sc: ${PYSOURCES} Makefile
161161
sloccount --duplicates --wide --details $^ > $@
@@ -169,8 +169,7 @@ list-author-emails:
169169
@git log --format='%aN,%aE' | sort -u | grep -v 'root'
170170

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

175174
jenkins:
176175
if ! test -d env ; then virtualenv env ; fi

schema_salad/ref_resolver.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,7 @@ def resolve_ref(self, ref, base_url=None):
268268
if not isinstance(ref, (str, unicode)):
269269
raise ValueError("Must be string: `%s`" % str(ref))
270270

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))
271+
url = self.expand_url(ref, base_url, scoped=(obj is not None))
274272

275273
# Has this reference been loaded already?
276274
if url in self.idx:
@@ -316,7 +314,7 @@ def resolve_ref(self, ref, base_url=None):
316314
return obj, metadata
317315

318316
def resolve_all(self, document, base_url, file_base=None):
319-
# type: (Any, Union[str, unicode], Union[str, unicode]) -> Tuple[Any, Dict[str, str]]
317+
# type: (Any, Union[str, unicode], Union[str, unicode]) -> Tuple[Any, Dict[str, Any]]
320318
loader = self
321319
metadata = {} # type: Dict[str, Any]
322320
if file_base is None:
@@ -524,13 +522,11 @@ def validate_link(self, field, link):
524522
if isinstance(link, (str, unicode)):
525523
if field in self.vocab_fields:
526524
if link not in self.vocab and link not in self.idx and link not in self.rvocab:
527-
if not self.check_file(cast( # bug in mypy 0.3.1
528-
Union[str, unicode], link)): # fixed in mypy 0.4-dev
525+
if not self.check_file(link):
529526
raise validate.ValidationException(
530527
"Field `%s` contains undefined reference to `%s`" % (field, link))
531528
elif link not in self.idx and link not in self.rvocab:
532-
if not self.check_file(cast( # bug in mypy 0.3.1
533-
Union[str, unicode], link)): # fixed in mypy 0.4-dev
529+
if not self.check_file(link):
534530
raise validate.ValidationException(
535531
"Field `%s` contains undefined reference to `%s`" % (field, link))
536532
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): ...

0 commit comments

Comments
 (0)