Remove use of 2to3#90
Conversation
and use six instead
- Replace Long trait type with Int - Do not modify dictionary during iteration modified: apptools/io/h5/dict_node.py modified: apptools/persistence/tests/test_state_pickler.py
|
The failures are now Python 2 only. See job https://travis-ci.org/enthought/apptools/jobs/531612677 |
Explicitly use long type in the type map used to pickle values in StatePickler modified: apptools/persistence/state_pickler.py new file: apptools/persistence/tests/__init__.py modified: apptools/persistence/tests/test_state_pickler.py
Codecov Report
@@ Coverage Diff @@
## master #90 +/- ##
=========================================
Coverage ? 40.51%
=========================================
Files ? 240
Lines ? 8912
Branches ? 1158
=========================================
Hits ? 3611
Misses ? 5155
Partials ? 146
Continue to review full report at Codecov.
|
jwiggins
left a comment
There was a problem hiding this comment.
I think the blanket use of from __future__ import absolute_import is of dubious usefulness.
Additionally, it might be worth the time to examine each of the files where six.moves is being used. Specifically, map, zip, and range might be OK as is.
- and remove a debugging statement - and remove an unnecessary use of six.text_type instead of unicode - and remove an overzealous correction made by modernize - and replace usage of sys python version with six
| def items(self): | ||
| with self._lock: | ||
| return self._cache.items() | ||
| return list(self._cache.items()) |
There was a problem hiding this comment.
Similar to an earlier question regd H5DictNode, should the items/keys/values methods return iterables on Python 3 or should they return lists?
There was a problem hiding this comment.
I want to say they should return iterables, but the locking presents a thorny problem. Perhaps the safest solution would be to implement this as an iterator (explicitly yield-ing items) on Python 3, and using the old/existing implementation on Python 2.
There was a problem hiding this comment.
I'd prefer leaving this change as-is, mainly because we're interested in removing LRUCache. Is that okay?
- and remove unnecessarily choosing between Int/Long trait types between Python 2 and Python 3 - and fix an error where the import was renamed in a module but not all usages were updated - remove a few unnecessary six.iteritems calls and replace them with dict.items. Except for in onecase where we were dealing with H5 files, in which case, it stays iteritems
and replace it with just calls to dict.items instead and rename a few absolute imports to be full instead of implicit modified: apptools/appscripting/script_manager.py modified: apptools/io/__init__.py modified: apptools/naming/__init__.py modified: apptools/naming/adapter/__init__.py modified: apptools/naming/trait_defs/__init__.py modified: apptools/scripting/recorder.py modified: apptools/type_manager/__init__.py
modified: apptools/type_manager/adapter_manager.py
- rewrite statement into a list comprehension instead of being wrapping calls to map and zip with list multiple times - return list/iterable on python 2/3 respectively, instead of returning list on both 2/3. modified: apptools/io/h5/dict_node.py modified: apptools/io/h5/tests/test_file.py
|
@jwiggins @corranwebster this PR is ready for review. again. for the last time, i thnk. |
- remove unnecessary use of list - move imports around to maintain consistency modified: apptools/io/h5/table_node.py modified: apptools/io/h5/tests/test_file.py modified: apptools/lru_cache/tests/test_lru_cache.py modified: apptools/naming/trait_defs/naming_traits.py modified: apptools/naming/ui/context_node_type.py modified: apptools/preferences/preferences.py modified: apptools/preferences/tests/preferences_test_case.py modified: apptools/preferences/ui/preferences_node.py modified: apptools/scripting/recorder.py modified: apptools/sweet_pickle/tests/updater_test_case.py
- moving imports around and adding spaces between imports and functions/classes - remove unnecessary uses of list modified: apptools/help/help_plugin/action/load_url_action.py modified: apptools/help/help_plugin/help_code.py modified: apptools/help/help_plugin/help_doc.py modified: apptools/preferences/preferences.py modified: apptools/preferences/tests/py_config_file.py modified: apptools/template/impl/template_data_context.py modified: apptools/type_registry/type_registry.py
Re-add a list call which actually is needed as the output is a tuple instead of a list modified: apptools/io/h5/tests/test_file.py
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #90 +/- ##
=========================================
Coverage ? 40.51%
=========================================
Files ? 240
Lines ? 8912
Branches ? 1158
=========================================
Hits ? 3611
Misses ? 5155
Partials ? 146 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Use
sixinsteadWARNING : I usedmodernizeto make automated changes to the codebase. I then added the recommended changes without much review. As such, this PR might include changes which are not absolutely necessary to the functionality of the package. If necessary, I can review the changes and remove the unnecessary/overzealous changes.