Skip to content

remove __getstate__ methods and use transient metadata#804

Merged
aaronayres35 merged 4 commits into
masterfrom
use-transient-metadata
Jun 2, 2021
Merged

remove __getstate__ methods and use transient metadata#804
aaronayres35 merged 4 commits into
masterfrom
use-transient-metadata

Conversation

@aaronayres35
Copy link
Copy Markdown
Contributor

@aaronayres35 aaronayres35 commented Apr 28, 2021

closes #795

This PR simply replaces the use of __getstate__ methods by setting transient metadata on relevant traits. HasTraits handles this with its own __getstate__ method appropriately.

EDIT: It also removes the unused _scroll_origin attribute on AbstractWindow.

Comment thread enable/abstract_window.py
self._update_region = []

def __getstate__(self):
attribs = ("component", "bgcolor", "overlay", "_scroll_origin")
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.

_scroll_origin is set to (0,0) in the __init__ method, but I don't see it used anywhere. A search of the chaco and enable codebases yields 0 results. Perhaps it can just be removed entirely?

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.

Yeah, it should probably just be removed. I also don't see it being used in some older internal codebases.

Comment thread enable/abstract_window.py

# (dx, dy) integer size of the Window.
_size = Trait(None, Tuple)
_size = Trait(None, Tuple, transient=True)
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 added transient=True for all traits that were previously explicitly listed in __getstate__ to preserve behavior. Perhaps we should re-evaluate though what actually should/shouldn't be transient

@aaronayres35 aaronayres35 changed the title [WIP] remove __getstate__ methods and use transient metadata remove __getstate__ methods and use transient metadata Apr 28, 2021
@rahulporuri rahulporuri self-requested a review April 28, 2021 14:56
Copy link
Copy Markdown
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.

LGTM with one suggestion

Comment thread enable/abstract_window.py Outdated
Co-authored-by: Poruri Sai Rahul <rporuri@enthought.com>
@aaronayres35 aaronayres35 merged commit 6e1c93e into master Jun 2, 2021
@aaronayres35 aaronayres35 deleted the use-transient-metadata branch June 2, 2021 13:48
aaronayres35 added a commit that referenced this pull request Jun 10, 2021
* remove __getstate__ methods and use transient metadata

* remove _scroll_origin

* Update enable/abstract_window.py

Co-authored-by: Poruri Sai Rahul <rporuri@enthought.com>

Co-authored-by: Poruri Sai Rahul <rporuri@enthought.com>
aaronayres35 added a commit that referenced this pull request Jun 11, 2021
* remove __getstate__ methods and use transient metadata (#804)

* remove __getstate__ methods and use transient metadata

* remove _scroll_origin

* Update enable/abstract_window.py

Co-authored-by: Poruri Sai Rahul <rporuri@enthought.com>

Co-authored-by: Poruri Sai Rahul <rporuri@enthought.com>

* Set transient metadata and pull up __getstate__ method (#841)

* set transient metadata on traits who (according to subclasses) should be transient

* import Int

* actually we do need getstate because stack_index is a class attribute.  Pull getstate method down here to the baseclass

* remove PICKLE FIXME comment

Co-authored-by: Poruri Sai Rahul <rporuri@enthought.com>

Co-authored-by: Poruri Sai Rahul <rporuri@enthought.com>

Co-authored-by: Poruri Sai Rahul <rporuri@enthought.com>
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.

Mark traits as "transient" instead of explicitly overriding traits __getstate__

3 participants