Skip to content
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

Replace use of 2to3 with six #355

Merged
merged 20 commits into from
Mar 7, 2019
Merged

Replace use of 2to3 with six #355

merged 20 commits into from
Mar 7, 2019

Conversation

rahulporuri
Copy link
Contributor

@rahulporuri rahulporuri commented Feb 16, 2019

modernize was used to make the necessary changes.
The changes introduced in this PR are :

  • remove use of xrange
  • remove use of basestring and unicode
  • update use of exception statement
  • update use of raise statement
  • remove/replace use of print statement
  • make imports explcitly local
  • update modules imports to be 2/3 compat e.g. cStringIO, thread and cPickle
  • update dict-related methods i.e. has_key, values, keys, items
  • update function object attrs e.g. func_name

Poruri Sai Rahul added 17 commits February 16, 2019 19:52
- use of `...` instead of '...'
- defining a tuple in the function definition

	modified:   pyface/tree/node_tree.py
	modified:   pyface/wx/shell.py
and replace with the equivalent use of collections.abc.Sequence
	modified:   pyface/action/group.py
	modified:   pyface/util/fix_introspect_bug.py
i.e. keys, values, items/iteritems
	modified:   pyface/i_window.py
	modified:   pyface/tasks/traits_task_pane.py
	modified:   pyface/ui/wx/tasks/dock_pane.py
	modified:   pyface/ui/wx/tasks/editor_area_pane.py
	modified:   pyface/tasks/action/task_action_manager_builder.py
which got added by mistake.
should have added the .bak files to the gitignore list
	modified:   pyface/i_window.py
@codecov-io
Copy link

codecov-io commented Feb 16, 2019

Codecov Report

Merging #355 into master will increase coverage by 0.04%.
The diff coverage is 45.17%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #355      +/-   ##
==========================================
+ Coverage   35.12%   35.17%   +0.04%     
==========================================
  Files         463      463              
  Lines       25732    25769      +37     
  Branches     3831     3830       -1     
==========================================
+ Hits         9039     9063      +24     
- Misses      16311    16324      +13     
  Partials      382      382
Impacted Files Coverage Δ
pyface/ui/wx/layered_panel.py 28.78% <0%> (ø) ⬆️
pyface/ui/wx/image_list.py 0% <0%> (ø) ⬆️
pyface/ui/qt4/tasks/editor_area_pane.py 22.22% <0%> (ø) ⬆️
pyface/wx/spreadsheet/default_renderer.py 0% <0%> (ø) ⬆️
pyface/ui/qt4/wizard/wizard.py 0% <0%> (ø) ⬆️
pyface/tree/trait_dict_node_type.py 0% <0%> (ø) ⬆️
pyface/wx/grid/grid_model.py 0% <0%> (ø) ⬆️
pyface/dock/dock_window.py 21.85% <0%> (ø) ⬆️
pyface/ui/wx/ipython_widget.py 0% <0%> (ø) ⬆️
pyface/wx/spreadsheet/virtual_model.py 0% <0%> (ø) ⬆️
... and 65 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 0a66dc7...62e9bce. Read the comment docs.

@rahulporuri
Copy link
Contributor Author

rahulporuri commented Feb 16, 2019

That was surprising. There was a broken import which got fixed in the commit ac76443 which has surprisingly fixed the test failures. Not sure why though.

As can be seen from the travis job - https://travis-ci.org/enthought/pyface/builds/494249473, the test failures are only on python 2.

The test failures on Python seem to be related to qt-api preparation. See traceback below for python 2 and toolkit pyqt on rh6.

$ edm run -e pyface-test-2.7-pyqt -- python -m nose pyface/tasks/tests/test_dock_pane_toggle_group.py 
E
======================================================================
ERROR: Failure: ValueError (API 'QDate' has already been set to version 1. Pyface expects PyQt API 2 under Python 2. Either import Pyface before any other Qt-using packages, or explicitly set the API before importing any other Qt-using packages.)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/rporuri/.edm/envs/pyface-test-2.7-pyqt/lib/python2.7/site-packages/nose/loader.py", line 420, in loadTestsFromName
    addr.filename, addr.module)
  File "/home/rporuri/.edm/envs/pyface-test-2.7-pyqt/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/home/rporuri/.edm/envs/pyface-test-2.7-pyqt/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/rporuri/Github/work/pyface/pyface/tasks/tests/test_dock_pane_toggle_group.py", line 5, in <module>
    from pyface.tasks.action.api import SMenu, SMenuBar, SGroup, \
  File "/home/rporuri/Github/work/pyface/pyface/tasks/action/api.py", line 13, in <module>
    from .dock_pane_toggle_group import DockPaneToggleGroup
  File "/home/rporuri/Github/work/pyface/pyface/tasks/action/dock_pane_toggle_group.py", line 5, in <module>
    from pyface.action.api import Action, ActionItem, Group
  File "/home/rporuri/Github/work/pyface/pyface/action/api.py", line 15, in <module>
    from .action_item import ActionItem
  File "/home/rporuri/Github/work/pyface/pyface/action/action_item.py", line 25, in <module>
    from pyface.toolkit import toolkit_object
  File "/home/rporuri/Github/work/pyface/pyface/toolkit.py", line 27, in <module>
    toolkit = toolkit_object = find_toolkit('pyface.toolkits')
  File "/home/rporuri/Github/work/pyface/pyface/base_toolkit.py", line 272, in find_toolkit
    toolkit = plugin.load()
  File "/home/rporuri/.edm/envs/pyface-test-2.7-pyqt/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2408, in load
    return self.resolve()
  File "/home/rporuri/.edm/envs/pyface-test-2.7-pyqt/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2414, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/home/rporuri/Github/work/pyface/pyface/ui/qt4/init.py", line 18, in <module>
    from pyface.qt import QtCore, QtGui, qt_api
  File "/home/rporuri/Github/work/pyface/pyface/qt/__init__.py", line 82, in <module>
    prepare_pyqt4()
  File "/home/rporuri/Github/work/pyface/pyface/qt/__init__.py", line 44, in prepare_pyqt4
    raise ValueError(msg)
ValueError: API 'QDate' has already been set to version 1. Pyface expects PyQt API 2 under Python 2. Either import Pyface before any other Qt-using packages, or explicitly set the API before importing any other Qt-using packages.

----------------------------------------------------------------------

For now, the Sequence import should be collections.Sequence,
which might need to change in future versions of Python

	modified:   pyface/resource/resource_manager.py
@rahulporuri rahulporuri changed the title Remove use of 2to3 Replace use of 2to3 with six Feb 18, 2019
@corranwebster
Copy link
Contributor

Thanks for doing this - it has been on my to-do list for a while but have not gotten around to it.

Copy link
Contributor

@corranwebster corranwebster left a comment

Choose a reason for hiding this comment

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

A couple of glitches in print statements, but otherwise looks good to me.

Poruri Sai Rahul added 2 commits March 6, 2019 13:15
- remove unnecessary parenthesis in print function call
- cleanup creation of set

	modified:   pyface/timer/tests/test_timer.py
	modified:   pyface/ui/qt4/console/console_widget.py
instead of passing the elements of the list, which is obviously
wrong

	modified:   pyface/ui/qt4/console/console_widget.py
@corranwebster corranwebster merged commit e047d8b into master Mar 7, 2019
@corranwebster corranwebster deleted the ref/remove-2to3 branch March 7, 2019 08:25
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.

None yet

3 participants