Skip to content

Remove use of 2to3#90

Merged
rahulporuri merged 12 commits into
masterfrom
feat/remove-2to3
May 29, 2019
Merged

Remove use of 2to3#90
rahulporuri merged 12 commits into
masterfrom
feat/remove-2to3

Conversation

@rahulporuri
Copy link
Copy Markdown
Contributor

@rahulporuri rahulporuri commented Mar 12, 2019

Use six instead

WARNING : I used modernize to 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.

and use six instead
@rahulporuri rahulporuri marked this pull request as ready for review March 12, 2019 00:47
- 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
@rahulporuri
Copy link
Copy Markdown
Contributor Author

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-io
Copy link
Copy Markdown

codecov-io commented May 13, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@1521e34). Click here to learn what that means.
The diff coverage is 43.17%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #90   +/-   ##
=========================================
  Coverage          ?   40.51%           
=========================================
  Files             ?      240           
  Lines             ?     8912           
  Branches          ?     1158           
=========================================
  Hits              ?     3611           
  Misses            ?     5155           
  Partials          ?      146
Impacted Files Coverage Δ
apptools/undo/i_command_stack.py 100% <ø> (ø)
apptools/undo/api.py 100% <ø> (ø)
apptools/undo/action/api.py 0% <ø> (ø)
...tools/undo/action/abstract_command_stack_action.py 0% <ø> (ø)
apptools/undo/i_undo_manager.py 100% <ø> (ø)
apptools/undo/action/undo_action.py 0% <ø> (ø)
apptools/undo/action/command_action.py 0% <ø> (ø)
apptools/undo/action/redo_action.py 0% <ø> (ø)
apptools/undo/command_stack.py 76.72% <ø> (ø)
apptools/undo/abstract_command.py 100% <ø> (ø)
... and 139 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1521e34...dce4f24. Read the comment docs.

@rahulporuri rahulporuri changed the title [WIP] Remove use of 2to3 Remove use of 2to3 May 13, 2019
Copy link
Copy Markdown
Member

@jwiggins jwiggins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread apptools/appscripting/script_manager.py Outdated
Comment thread apptools/io/h5/file.py Outdated
Comment thread apptools/io/h5/table_node.py Outdated
Comment thread apptools/io/__init__.py Outdated
Comment thread apptools/io/h5/tests/test_dict_node.py Outdated
Comment thread apptools/type_manager/adapter_manager.py Outdated
Comment thread apptools/type_manager/adapter_manager.py
Comment thread apptools/type_manager/adapter_manager.py
Comment thread apptools/type_registry/tests/dummies.py
Comment thread apptools/undo/tests/test_command_stack.py Outdated
Poruri Sai Rahul added 2 commits May 13, 2019 14:15
- 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
Comment thread apptools/undo/tests/test_command_stack.py
Comment thread apptools/io/h5/dict_node.py Outdated
def items(self):
with self._lock:
return self._cache.items()
return list(self._cache.items())
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to an earlier question regd H5DictNode, should the items/keys/values methods return iterables on Python 3 or should they return lists?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer leaving this change as-is, mainly because we're interested in removing LRUCache. Is that okay?

Poruri Sai Rahul added 4 commits May 13, 2019 15:26
- 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
@rahulporuri
Copy link
Copy Markdown
Contributor Author

@jwiggins @corranwebster this PR is ready for review. again. for the last time, i thnk.

@rahulporuri rahulporuri mentioned this pull request May 18, 2019
Comment thread apptools/io/h5/table_node.py
Comment thread apptools/io/h5/tests/test_file.py
Comment thread apptools/lru_cache/tests/test_lru_cache.py
Comment thread apptools/lru_cache/tests/test_lru_cache.py Outdated
Comment thread apptools/naming/trait_defs/naming_traits.py
Comment thread apptools/preferences/preferences.py
Comment thread apptools/preferences/tests/preferences_test_case.py Outdated
Comment thread apptools/preferences/ui/preferences_node.py Outdated
Comment thread apptools/scripting/recorder.py Outdated
Comment thread apptools/sweet_pickle/tests/updater_test_case.py Outdated
Poruri Sai Rahul added 3 commits May 29, 2019 14:25
- 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
@rahulporuri rahulporuri merged commit 30cd14d into master May 29, 2019
@rahulporuri rahulporuri deleted the feat/remove-2to3 branch May 29, 2019 09:59
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 43.17673% with 254 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@1521e34). Learn more about missing BASE report.

Files with missing lines Patch % Lines
apptools/appscripting/script_manager.py 0.00% 12 Missing ⚠️
apptools/permissions/default/user_database.py 0.00% 10 Missing ⚠️
apptools/template/api.py 0.00% 9 Missing ⚠️
apptools/permissions/api.py 0.00% 8 Missing ⚠️
apptools/permissions/default/role_definition.py 0.00% 8 Missing ⚠️
apptools/help/help_plugin/help_submenu_manager.py 0.00% 7 Missing ⚠️
apptools/naming/ui/api.py 0.00% 7 Missing ⚠️
apptools/permissions/default/policy_manager.py 0.00% 7 Missing ⚠️
apptools/template/impl/api.py 0.00% 7 Missing ⚠️
apptools/appscripting/api.py 0.00% 6 Missing ⚠️
... and 77 more
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants