I took a quick look into what it would take to part ways with the py23 module imports within the project and it is significant. The following is a ballpark estimate of matched strings in modules under Lib/fontTools/ that does not account for a py23 module import statement in the match. This may be an over count for the strings that are Python builtins/stdlib.
basestring: 43 matches across 19 filesbytechr: 65 matches across 16 filesbyteord: 112 matches across 32 filesBytesIO: 35 matches across 19 filesbytesjoin: 89 matches across 32 filesopen: 277 matches across 49 filesPy23Error: 3 matches in 1 filerange: 897 matches across 109 filesRecursionError: 4 matches across 2 filesround: 302 matches across 50 filesSimpleNamespace: 18 matches across 4 filesStringIO: 9 matches across 7 filesstrjoin: 24 matches across 15 filesTag: 744 matches across 47 filestobytes: 70 matches across 37 filestostr: 31 matches across 18 filestounicode: 33 matches across 13 filesUnicodeIO: 5 matches across 3 filesxrange: 3 matches in 1 filezip: 176 matches across 39 filesAny interest in beginning to chip away at this?
Related #2231
TODO:
basestring with str #2241 UnicodeIO with StringIO and import from io moduletounicode with tostrBytesIO from io moduleSimpleNamespace from types modulepy23.bytechr to new modulepy23.byteord to new modulepy23.bytesjoin to new modulepy23.strjoin to new modulepy23.tobytes to new modulepy23.tostr to new modulepy23.Tag to new modulemisc.py23 import statementsSome of these are easy to fix. basestring should be unconditionally replaced with str, UnicodeIO with StringIO and both should be imported from io module together with BytesIO. SimpleNamespace should be imported from types module.
open, round, range, zip need no change, py23 is already using the Python 3 builtin, so removing the import is all needed.
bytechr, byteord, bytesjoin, strjoin, tobytes, tostr and Tag class seem useful and should probably be moved to a different module (misc.textTools?). tounicode is another name for tostr and should be simply replaced with it.
basestring to str https://github.com/fonttools/fonttools/pull/2241
Most helpful comment
Some of these are easy to fix.
basestringshould be unconditionally replaced withstr,UnicodeIOwithStringIOand both should be imported fromiomodule together withBytesIO.SimpleNamespaceshould be imported fromtypesmodule.open,round,range,zipneed no change,py23is already using the Python 3 builtin, so removing the import is all needed.bytechr,byteord,bytesjoin,strjoin,tobytes,tostrandTagclass seem useful and should probably be moved to a different module (misc.textTools?).tounicodeis another name fortostrand should be simply replaced with it.