Repository navigation
[MRG] Working towards python3 compatible codebase - #109
Conversation
|
What happens if you add |
|
looking good! |
|
@tetron It allows in a Python 2 program to have the default interpretation of string literals be Unicode (UTF8). That is, is equivalent to except that I don’t have to prefix every single string with u to treat it as a Unicode literal. Looks good to me, but it seems to have drawbacks too as highlighted in this article: http://python-future.org/unicode_literals.html |
|
Thanks for the link. If possible, I'd prefer to use Unicode strings consistently. Some string literals are already marked with The main client of schema-salad is |
|
Thanks for the heads up.
Yes, this is my main concern too.
Sure, I will try this approach. Interested to see how this works out. I think it would be better to get this PR merged before getting on with it. Would keep things simpler |
|
Here's how I would like to do this. The goal is minimize the number of merges & schema-salad releases in the event there are issues in schema salad that turn up while porting cwltool.
|
|
I like the overall workflow. This would give me a chance to see how changes in |
|
Nice 😃 |
|
About typesheds for python3, there are already many of them in python typeshed repo https://github.com/AleksandrSl/schema_salad/blob/python3-support/typeshed.md. I have raised issues about typeshed addition about two months ago in mistune in cachecontrol repos, but got no answer so far, so I think I will try to write them myself. Is there any modules that I've not mentioned or haven't find ready typesheds for? |
aa13415 to
8c17480
Compare
|
Updates:
|
|
@AleksandrSl Thanks so much for compiling this. Before running I will go through your typshed list and try to update it for the missing fields. Also, we've used stubgen for some of the 3rd party dependencies so far. So, need to decide if we will continue with that or write our own stubs for some of them. |
05fdce9 to
b034a36
Compare
|
|
||
| g = makerdf(None, ra, ctx) | ||
| print(g.serialize(format="n3")) | ||
| print((g.serialize(format="n3"))) |
There was a problem hiding this comment.
Why do we wrap these expressions in additional parentheses? Just wondering
There was a problem hiding this comment.
this change was done by modernize fixture. I'll fix it.
| deps = | ||
| mypy==0.470 | ||
| typed-ast==0.6.3 | ||
| -rrequirements.txt |
There was a problem hiding this comment.
six requirement missing in requirements.txt
There was a problem hiding this comment.
Earlier the tests were passing because six was being satisfied as a requirement of some other package. I will add it as an explicit dependency now.
I believe I should add in setup.py rather than requirements.txt because it is required beyond testing.
| jsonldPredicate=None # type: Optional[Dict[str, str]] | ||
| ): | ||
| # type: (...) -> Union[str, unicode] | ||
| # type: (...) -> Union[str, Text] |
There was a problem hiding this comment.
Isn't Text an alias for str in python3 and unicode in python2, why mention str separately?
There was a problem hiding this comment.
Separately mentioning is redundant in python3 indeed, but in case of python2 union states that this function can return ASCII strings as well as unicode strings.
# type: (...) -> Union[str, unicode] annotation was already present, I just made sure Text type makes it compatible with python3.
There was a problem hiding this comment.
@manu-chroma It seems, though, that simple Text is enough.
"When checking Python 2.7 code, type checkers should treat the int and long types as equivalent. For parameters typed as unicode or Text , arguments of type str should be acceptable." from PEP484
I checked this with mypy, str and unicode pass for Text in python2 and str for Text in python3
There was a problem hiding this comment.
@AleksandrSl Thanks for the clarifying this. 😄
I will make changes wherever required in PR #111
Main changes: - use of __future__ - using six lib to: - deal with checking unicode - dict operations - other API changes
|
In the process of rebasing and resolving merge conflicts, I ended up having some commits messages appearing twice. Just messed up commit history a little. 😓 edit: around 3-4 commits. shouldn't be a problem |
| for d in six.itervalues(r): | ||
| _add_lc_filename(d, source) | ||
|
|
||
| def relname(source): # type: (AnyStr) -> AnyStr |
There was a problem hiding this comment.
Any particular reason this was marked as AnyStr? I don't expect this to take binary strings.
| def add_lc_filename(r, source): # type: (ruamel.yaml.comments.CommentedBase, Text) -> None | ||
| _add_lc_filename(r, relname(source)) | ||
|
|
||
| def reflow(text, maxline, shift=""): # type: (AnyStr, int, AnyStr) -> AnyStr |
There was a problem hiding this comment.
query same as above.
|
This branch is pretty mature now. I would like to get it reviewed and merged now. |
|
|
||
| install_requires.append("avro") # TODO: remove me once cwltool is | ||
| # install_requires.append("avro") # TODO: remove me once cwltool is | ||
| # available in Debian Stable, Ubuntu 12.04 LTS |
|
|
||
| setup(name='schema-salad', | ||
| version='2.5', | ||
| version='3.0', |
There was a problem hiding this comment.
Is the API really different? Does the current released version ofcwltool still pass its tests and the CWL conformance tests which this branch? If not, then 2.6 or 2.5.1 is fine.
There was a problem hiding this comment.
This version bump was motivated by @tetron's comment.
#109 (comment)
There was a problem hiding this comment.
in the event there are issues in schema salad that turn up while porting cwltool.
So let's test that as I mentioned in my previous comment
There was a problem hiding this comment.
Does the current released version of
cwltoolstill pass its tests and the CWL conformance tests which this branch?
conformace and unit tests pass
this is due to changes made when upgrading mypy to 0.511 for schema_salad. But cwltool master is still uses mypy==0.470.
There was a problem hiding this comment.
we can selectively silence errors due to schema_salad using mypy config file until mypy==0.511 changes are not merged in cwltool.
There was a problem hiding this comment.
That's fine, as long as we fix it this week.
There was a problem hiding this comment.
yeah. I'm preparing cwltool PR to get reviewed soon.
| }, | ||
| zip_safe=True, | ||
| cmdclass={'egg_info': tagger}, | ||
| # cmdclass={'egg_info': tagger}, |
There was a problem hiding this comment.
i've fixed it.
when testing with cwltool earlier, it was giving me errors related to requirement parsing. thought commenting this out might help. forgot to uncomment.
|
|
||
| setup(name='schema-salad', | ||
| version='2.5', | ||
| version='3.0', |
There was a problem hiding this comment.
Change this to 2.5.1 to 2.6 and I'll merge it!
|
Huzzah! Thank you @manu-chroma |
|
thank you @mr-c 😅 |
|
next PR for |
Related issue checklist: #108
I'd prefer if the commits from this branch are preserved when merging into the master. This will ensure that future potential issues are easier to bisect. That's why I've ensured that the commit history is clean and commit messages are informative.