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

Copy Undo over from apptools #813

Merged
merged 14 commits into from
Dec 1, 2020
Merged

Copy Undo over from apptools #813

merged 14 commits into from
Dec 1, 2020

Conversation

aaronayres35
Copy link
Contributor

As mentioned in step 6a of https://github.com/enthought/ets/blob/master/docs/source/eeps/eep-6.rst
this PR simply copies over the apptools.undo subpackage from apptools (and updates references to apptools in the code to reference pyface instead).

After the next pyface release we will want to deprecate apptools.undo in apptools.

@codecov-io
Copy link

codecov-io commented Nov 25, 2020

Codecov Report

Merging #813 (012e27f) into master (0d1516e) will increase coverage by 0.43%.
The diff coverage is 88.97%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #813      +/-   ##
==========================================
+ Coverage   40.81%   41.25%   +0.43%     
==========================================
  Files         508      522      +14     
  Lines       27845    28110     +265     
  Branches     4219     4251      +32     
==========================================
+ Hits        11366    11596     +230     
- Misses      15999    16018      +19     
- Partials      480      496      +16     
Impacted Files Coverage Δ
pyface/ui/wx/tree/tree.py 0.00% <ø> (ø)
pyface/workbench/workbench.py 53.19% <50.00%> (ø)
pyface/undo/action/command_action.py 64.28% <64.28%> (ø)
pyface/workbench/i_editor.py 65.78% <66.66%> (ø)
pyface/undo/undo_manager.py 81.81% <81.81%> (ø)
...yface/undo/action/abstract_command_stack_action.py 86.66% <86.66%> (ø)
pyface/undo/command_stack.py 89.65% <89.65%> (ø)
pyface/undo/action/redo_action.py 91.66% <91.66%> (ø)
pyface/undo/action/undo_action.py 91.66% <91.66%> (ø)
pyface/i_widget.py 100.00% <100.00%> (ø)
... and 40 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 4751783...012e27f. Read the comment docs.

Copy link
Contributor

@rahulporuri rahulporuri left a comment

Choose a reason for hiding this comment

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

  1. Can you also move the documentation for undo from apptools to pyface?
  2. Can you also move the examples for undo from apptools to pyface?
  3. Can you check the test coverage for all of the new code? I think we will want to/need to add more tests.


# This is the currently active command stack and may be None. Typically it
# is set when some sort of editor becomes active.
active_stack = Instance("apptools.undo.api.ICommandStack")
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure why we can't just import and use ICommandStack here instead of using the string.

Copy link
Contributor

Choose a reason for hiding this comment

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

There is a circular import, I think - UndoManager references ICommandStack and vice-versa.


# This is the currently active command stack and may be None. Typically it
# is set when some sort of editor becomes active.
active_stack = Instance("apptools.undo.api.ICommandStack")
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like IUndoManager and ICommandStack depend on one another - which is why we can't import and use ICommandStack here. Can you add a comment here regarding the same?



.. _API: api/index.html
.. _example: https://svn.enthought.com/enthought/browser/AppTools/trunk/examples/undo/
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This link is clearly out of place here, but I believe it was actually previously broken on apptools as well. Likewise, this final section of "API Overview" seems unnecessary with auto built api docs. This file needs to be updated, but I think I will leave those changes for a separate PR unless a reviewer would like to see them done here, in which case I am happy to do so

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's get them fixed in this PR instead of after the PR.

@aaronayres35
Copy link
Contributor Author

aaronayres35 commented Nov 30, 2020

  1. Can you check the test coverage for all of the new code? I think we will want to/need to add more tests.

Here is a screenshot of the coverage report:
Screen Shot 2020-11-30 at 9 05 47 AM

Some of these would benefit from additional tests (looks like undo_manager specifically) as you mentioned. Should I try to write them as part of this PR, or do that in a subsequent PR @rahulporuri?

@rahulporuri
Copy link
Contributor

Should I try to write them as part of this PR, or do that in a subsequent PR @rahulporuri?

Can you add those as part of this PR? IMO its not too much to review.

@aaronayres35
Copy link
Contributor Author

pyface.undo.action is currently untested, but I am unsure on what the benefits would be of testing. The classes exposed by the api basically just have a perform method which calls a method on command_stack or undo_manager which are already tested. Also, testing if perform works is handled by the tests for Action. It feels incorrect to leave this sub package without tests, but I am unsure what specifically it would be useful to test (rather than just writing noisy tests for the sake of writing something).

One thing I see that may be beneficial is AbstractCommandStackAction has a method _on_stack_updated that simply calls self._update_action() when the active_stack is updated. This can change whether the actions are enabled, and their names, and probably warrants a test.

Copy link
Contributor

@rahulporuri rahulporuri left a comment

Choose a reason for hiding this comment

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

Mostly LGTM with a few minor comments.


# Enthought library imports.
from pyface.api import GUI, YES
from pyface.workbench.api import Workbench
Copy link
Contributor

Choose a reason for hiding this comment

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

can you open an issue regd porting the undo example code from pyface workbench to pyface tasks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opened #821

@rahulporuri
Copy link
Contributor

@aaronayres35 before you merge, can you update the coverage report?

@aaronayres35
Copy link
Contributor Author

  1. Can you check the test coverage for all of the new code? I think we will want to/need to add more tests.

Here is a screenshot of the coverage report:
Screen Shot 2020-11-30 at 9 05 47 AM

This is the updated coverage report after the added tests:
Screen Shot 2020-12-01 at 8 06 37 AM

@aaronayres35 aaronayres35 merged commit 75709d0 into master Dec 1, 2020
@aaronayres35 aaronayres35 deleted the copy-undo-from-apptools branch December 1, 2020 14:12
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.

4 participants