diff --git a/Makefile b/Makefile index ad23179f0..bd4a87d7f 100644 --- a/Makefile +++ b/Makefile @@ -160,7 +160,7 @@ mypy2: ${PYSOURCES} rm -Rf typeshed/2and3/schema_salad ln -s $(shell python -c 'from __future__ import print_function; import schema_salad; import os.path; print(os.path.dirname(schema_salad.__file__))') \ typeshed/2and3/schema_salad - MYPYPATH=$MYPYPATH:typeshed/2.7:typeshed/2and3 mypy --py2 --disallow-untyped-calls \ + MYPYPATH=$$MYPYPATH:typeshed/2.7:typeshed/2and3 mypy --py2 --disallow-untyped-calls \ --warn-redundant-casts \ cwltool @@ -171,7 +171,7 @@ mypy3: ${PYSOURCES} rm -Rf typeshed/2and3/schema_salad ln -s $(shell python3 -c 'from __future__ import print_function; import schema_salad; import os.path; print(os.path.dirname(schema_salad.__file__))') \ typeshed/2and3/schema_salad - MYPYPATH=$MYPYPATH:typeshed/3:typeshed/2and3 mypy --disallow-untyped-calls \ + MYPYPATH=$$MYPYPATH:typeshed/3:typeshed/2and3 mypy --disallow-untyped-calls \ --warn-redundant-casts \ cwltool diff --git a/cwltool/draft2tool.py b/cwltool/draft2tool.py index bb5669269..5d572bb3a 100644 --- a/cwltool/draft2tool.py +++ b/cwltool/draft2tool.py @@ -1,14 +1,16 @@ from __future__ import absolute_import import copy import hashlib +import locale import json import logging import os import re import shutil import tempfile -from functools import partial -from typing import Any, Callable, Dict, Generator, List, Optional, Set, Text, Union, cast +from functools import partial, cmp_to_key +from typing import (Any, Callable, Dict, Generator, List, Optional, Set, Text, + Union, cast) from six import string_types, u @@ -208,7 +210,7 @@ def makeJobRunner(self, use_container=True, **kwargs): # type: (Optional[bool], }) dockerReq = self.requirements[0] if default_container == windows_default_container_id and use_container and onWindows(): - _logger.warning(DEFAULT_CONTAINER_MSG%(windows_default_container_id, windows_default_container_id)) + _logger.warning(DEFAULT_CONTAINER_MSG % (windows_default_container_id, windows_default_container_id)) if dockerReq and use_container: return DockerCommandLineJob() @@ -523,8 +525,8 @@ def collect_output_ports(self, ports, builder, outdir, compute_checksum=True, jo for i, port in enumerate(ports): def makeWorkflowException(msg): return WorkflowException( - u"Error collecting output for parameter '%s':\n%s" - % (shortname(port["id"]), msg)) + u"Error collecting output for parameter '%s':\n%s" + % (shortname(port["id"]), msg)) with SourceLine(ports, i, makeWorkflowException, debug): fragment = shortname(port["id"]) ret[fragment] = self.collect_output(port, builder, outdir, fs_access, @@ -575,16 +577,25 @@ def collect_output(self, schema, builder, outdir, fs_access, compute_checksum=Tr elif gb == ".": gb = outdir elif gb.startswith("/"): - raise WorkflowException("glob patterns must not start with '/'") + raise WorkflowException( + "glob patterns must not start with '/'") try: prefix = fs_access.glob(outdir) r.extend([{"location": g, - "path": fs_access.join(builder.outdir, g[len(prefix[0])+1:]), + "path": fs_access.join(builder.outdir, + g[len(prefix[0])+1:]), "basename": os.path.basename(g), - "nameroot": os.path.splitext(os.path.basename(g))[0], - "nameext": os.path.splitext(os.path.basename(g))[1], - "class": "File" if fs_access.isfile(g) else "Directory"} - for g in fs_access.glob(fs_access.join(outdir, gb))]) + "nameroot": os.path.splitext( + os.path.basename(g))[0], + "nameext": os.path.splitext( + os.path.basename(g))[1], + "class": "File" if fs_access.isfile(g) + else "Directory"} + for g in sorted(fs_access.glob( + fs_access.join(outdir, gb)), + key=cmp_to_key(cast( + Callable[[Text, Text], + int], locale.strcoll)))]) except (OSError, IOError) as e: _logger.warning(Text(e)) except: diff --git a/mypy.ini b/mypy.ini index 7985b2068..225366bc2 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,2 +1,4 @@ +[mypy] + [mypy-ruamel.*] ignore_errors = True diff --git a/tox.ini b/tox.ini index 0ba26628c..d34255c79 100644 --- a/tox.ini +++ b/tox.ini @@ -33,14 +33,14 @@ whitelist_externals = commands = make mypy2 whitelist_externals = make deps = - mypy==0.520 + mypy==0.560 -rrequirements.txt [testenv:py35-mypy3] commands = make mypy3 whitelist_externals = make deps = - mypy==0.520 + mypy==0.560 -rrequirements.txt [testenv:py27-pipconflictchecker]