-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[19.05] Run futurize for python2 cheetah templates, fix scope issue for py3 comprehensions #7867
[19.05] Run futurize for python2 cheetah templates, fix scope issue for py3 comprehensions #7867
Conversation
46f8641
to
4f7c193
Compare
Hah, turns out dict, set and generator comprehensions all have that problem on python 2, so I guess we don't need to fix that. |
7f53d90
to
d3821c0
Compare
832b241
to
02c4c46
Compare
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'd prefer to parse python_template_version
with packaging.version.parse()
instead of casting with float()
, see comments inline.
205b4a6
to
5cafb90
Compare
040f8e6
to
3d56230
Compare
This will allow tools to work that access variables from the enclosing scope in a list/dict/tuple comprehension.
Now if we could figure out the exact position in the template source where a NotFound error is raised we could replace `$variable` with `variable` and add `#variable = $variable` just before the failing statement.
…urrounding scope While fixable this seems to not work on python 2 either, so we will not attempt to fix it.
or python_template_version < 3.
We use a list of fixers from past.translation. This is just a list of strings pointing to fixers to import. Currently this is ``` ['libfuturize.fixes.fix_absolute_import', 'libfuturize.fixes.fix_print_with_import', 'libfuturize.fixes.fix_raise', 'libfuturize.fixes.fix_next_call', 'lib2to3.fixes.fix_reduce', 'lib2to3.fixes.fix_sys_exc', 'lib2to3.fixes.fix_throw', 'lib2to3.fixes.fix_tuple_params', 'lib2to3.fixes.fix_exec', 'lib2to3.fixes.fix_standarderror', 'lib2to3.fixes.fix_apply', 'lib2to3.fixes.fix_paren', 'lib2to3.fixes.fix_types', 'lib2to3.fixes.fix_methodattrs', 'lib2to3.fixes.fix_renames', 'lib2to3.fixes.fix_ws_comma', 'lib2to3.fixes.fix_repr', 'lib2to3.fixes.fix_intern', 'lib2to3.fixes.fix_numliterals', 'lib2to3.fixes.fix_funcattrs', 'lib2to3.fixes.fix_ne', 'lib2to3.fixes.fix_exitfunc', 'lib2to3.fixes.fix_has_key', 'lib2to3.fixes.fix_isinstance', 'lib2to3.fixes.fix_idioms', 'lib2to3.fixes.fix_xreadlines', 'lib2to3.fixes.fix_except', 'libfuturize.fixes.fix_execfile', 'libfuturize.fixes.fix_future_standard_library', 'libfuturize.fixes.fix_metaclass', 'libfuturize.fixes.fix_future_builtins', 'libpasteurize.fixes.fix_newstyle', 'libfuturize.fixes.fix_basestring', 'libfuturize.fixes.fix_future_standard_library_urllib', 'libfuturize.fixes.fix_xrange_with_import', 'libfuturize.fixes.fix_cmp', 'libfuturize.fixes.fix_unicode_keep_u', 'libfuturize.fixes.fix_division_safe', 'libfuturize.fixes.fix_object', 'lib2to3.fixes.fix_input', 'lib2to3.fixes.fix_operator', 'lib2to3.fixes.fix_zip', 'lib2to3.fixes.fix_dict', 'lib2to3.fixes.fix_next', 'lib2to3.fixes.fix_filter', 'lib2to3.fixes.fix_raw_input', 'lib2to3.fixes.fix_getcwdu', 'lib2to3.fixes.fix_itertools_imports', 'lib2to3.fixes.fix_nonzero', 'lib2to3.fixes.fix_itertools', 'lib2to3.fixes.fix_long', 'lib2to3.fixes.fix_map'] ``` And then we drop pasterurize, which we don't need for our purposes.
3d56230
to
a05d24c
Compare
f16cf9f
to
ccea1ee
Compare
@galaxybot test py3 |
merged forward |
I think this should cover the python 2/3 errors I have seen so far