Status: Valid
Owner: ----
Labels: Type-Defect Priority-Medium EasyToFix

New issue 3599 by asmeu...@gmail.com: Apply 2to3 "idioms" fixer to code base
http://code.google.com/p/sympy/issues/detail?id=3599

See http://docs.python.org/2/library/2to3.html#2to3fixer-idioms. If you run "2to3 -f idioms sympy", it will spit out a diff file with all the changes (note, make sure your 2to3 is the one that comes with Python 3, as the one with Python 2 is slower. Just check the shebang of the file at "which 2to3". For me, though, even the Python 3 one is slow).

You'll need to go through each change individually and make sure it is correct. It seems to do three things, change "type(x) is A" to "isinstance(x, A)", "while 1" to "while True", and "x = list(stuff); s.sort()" to "x = sorted(stuff)". The first is usually correct, but it isn't correct when a test file is checking the exact type of an object (note that isinstance(x, A) differs from "type(x) is A" in that the former also works if x is an instance of a subclass of A). The while loop fixer should always be applied. The list sorting fixer should be applied unless it would change the API (i.e., it really does need x to be a list, as maybe it returns it, or maybe it later indexes it). If it just indexes it, check if it's really necessary. So just remove the ones that don't seem relevant, and apply the diff using git apply or something.

Another relevant optional 2to3 fixer is ws_comma, which removes extra whitespace around commas, but I think most of those have already been fixed by recent PEP 8 PRs. The other two skipped fixers are buffer, which doesn't apply (we don't use buffer), and set_literal, which we can't use because set literals are Python 2.7+ only.

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to sympy-issues@googlegroups.com.
To unsubscribe from this group, send email to 
sympy-issues+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to