Skip to content

improve python3 support - #287

Merged
mr-c merged 6 commits into
common-workflow-language:masterfrom
gijzelaerr:py3
Feb 28, 2017
Merged

mr-c merged 6 commits into
common-workflow-language:masterfrom
gijzelaerr:py3

Conversation

@gijzelaerr

Copy link
Copy Markdown
Member

No description provided.

@mr-c

mr-c commented Feb 8, 2017

Copy link
Copy Markdown
Member

"This branch is out-of-date with the base branch" Should I hit the 'update branch' button, or do you want to do that locally?

Comment thread cwltool/expression.py
param_re = re.compile(r"\((%s)%s*\)$" % (seg_symbol, segments), flags=re.UNICODE)

JSON = Union[Dict[Any, Any], List[Any], Text, int, long, float, bool, None]
JSON = Union[Dict[Any, Any], List[Any], Text, int, int, float, bool, None]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm...

Comment thread cwltool/sandboxjs.py
_logger = logging.getLogger("cwltool")

JSON = Union[Dict[Text, Any], List[Any], Text, int, long, float, bool, None]
JSON = Union[Dict[Text, Any], List[Any], Text, int, int, float, bool, None]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread cwltool/sandboxjs.py
@@ -1,12 +1,11 @@
import cStringIO

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed on line 107

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes. clearly this is not covered by the test suite :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, it is not required to run the code, only to validate the types. But there are many more type violations due to missing imports in the code... so what should we do?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lines I commented on are the only type violations I'm aware of.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pycharm finds a lot, but that is mostly things like typing.List and typing.Union, which are probably imported by default by mypy.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, those should be added in, yes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks impossible to make that type annotation work properly with Python3, the stringio stuff works quite different now.

Comment thread cwltool/expression.py Outdated
key = int(m.group(0)[1:-1])
except ValueError as v:
raise WorkflowException(unicode(v))
raise WorkflowException(u(v))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cwltool/expression.py: note: In function "next_seg":
cwltool/expression.py:130: error: Argument 1 to "u" has incompatible type "ValueError"; expected "str"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where did you find these errors?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread cwltool/draft2tool.py Outdated
raise WorkflowException(
u"Error collecting output for parameter '%s':\n%s"
% (shortname(port["id"]), indent(unicode(e))))
% (shortname(port["id"]), indent(u(e))))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cwltool/draft2tool.py: note: In member "collect_output_ports" of class "CommandLineTool":
cwltool/draft2tool.py:410: error: Argument 1 to "u" has incompatible type "Exception"; expected "str"

Comment thread cwltool/sandboxjs.py
stdout_buf = BytesIO()
stderr_buf = BytesIO()

completed = [] # type: List[Union[cStringIO.InputType, cStringIO.OutputType]]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd try completed = [] # type: List[BytesIO] here ...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, but that is python3 only.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated schema_salad and cwltool for mypy 0.470 (the project was renamed from mypy-lang). With that in place type: List[BytesIO] works for me. If you'll merge in from master then I think we'll be done with this PR.

@mr-c

mr-c commented Feb 8, 2017

Copy link
Copy Markdown
Member

and add 3.4 & 3.6 to `.travis.yml' to turn those tests on

Comment thread cwltool/sandboxjs.py
stdout_buf = BytesIO()
stderr_buf = BytesIO()

completed = [] # type: List[Union[cStringIO.InputType, cStringIO.OutputType]]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated schema_salad and cwltool for mypy 0.470 (the project was renamed from mypy-lang). With that in place type: List[BytesIO] works for me. If you'll merge in from master then I think we'll be done with this PR.

This was referenced Feb 27, 2017
Merged
@mr-c
mr-c merged commit feec475 into common-workflow-language:master Feb 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants