-
-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[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
schema_salad/tests/test_examples.py
Outdated
@@ -299,7 +301,7 @@ def test_scoped_id(self): | |||
}, ra) | |||
|
|||
g = makerdf(None, ra, ctx) | |||
print(g.serialize(format="n3")) | |||
print((g.serialize(format="n3"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we wrap these expressions in additional parentheses? Just wondering
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change was done by modernize
fixture. I'll fix it.
tox.ini
Outdated
deps = | ||
mypy==0.470 | ||
typed-ast==0.6.3 | ||
-rrequirements.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
six
requirement missing in requirements.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
schema_salad/makedoc.py
Outdated
@@ -227,7 +234,7 @@ def typefmt(self, | |||
nbsp=False, # type: bool | |||
jsonldPredicate=None # type: Optional[Dict[str, str]] | |||
): | |||
# type: (...) -> Union[str, unicode] | |||
# type: (...) -> Union[str, Text] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't Text an alias for str in python3 and unicode in python2, why mention str separately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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 |
_add_lc_filename(d, source) | ||
|
||
def relname(source): # type: (AnyStr) -> AnyStr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason this was marked as AnyStr
? I don't expect this to take binary strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reason I can think of
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was before Text
was a thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alright. 👍
_add_lc_filename(r, relname(source)) | ||
|
||
def reflow(text, maxline, shift=""): # type: (AnyStr, int, AnyStr) -> AnyStr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
query same as above.
This branch is pretty mature now. I would like to get it reviewed and merged now. |
setup.py
Outdated
|
||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these lines can now be removed
setup.py
Outdated
|
||
setup(name='schema-salad', | ||
version='2.5', | ||
version='3.0', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This version bump was motivated by @tetron's comment.
#109 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the current released version of
cwltool
still pass its tests and the CWL conformance tests which this branch?
conformace and unit tests pass
mypy fails. https://travis-ci.org/manu-chroma/cwltool/jobs/247893307#L194
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine, as long as we fix it this week.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah. I'm preparing cwltool PR to get reviewed soon.
setup.py
Outdated
@@ -67,7 +69,7 @@ | |||
'console_scripts': ["schema-salad-tool=schema_salad.main:main", "schema-salad-doc=schema_salad.makedoc:main"] | |||
}, | |||
zip_safe=True, | |||
cmdclass={'egg_info': tagger}, | |||
# cmdclass={'egg_info': tagger}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.py
Outdated
|
||
setup(name='schema-salad', | ||
version='2.5', | ||
version='3.0', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this to 2.5.1 to 2.6 and I'll merge it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2.5.1 or 2.6?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think 2.5.1 is fine.
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.