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

Fix TraitType clone default values #1645

Merged
merged 14 commits into from
Aug 10, 2022
Merged

Conversation

corranwebster
Copy link
Contributor

@corranwebster corranwebster commented May 20, 2022

This is a draft PR working towards a fix of #1630 and related issues.

The starting point is a set of regression tests that identify the behaviour which doesn't seem correct and test for the expected behaviour. This then adds changes to TraitTypes.clone that fix a number of the observed issues. We then remove the default value wrangling in HasTraits as it should no longer be needed.

I think at this point everything is in a better state than it was: we have less unexpected behaviour.

There may be subsequent things which might be advisable, such as raising warnings about future deprecation of certain behaviours, adding clone methods to particular trait types, etc.

Checklist

  • Tests
  • Update API reference (docs/source/traits_api_reference)
  • Update User manual (docs/source/traits_user_manual)
  • Update type annotation hints in traits-stubs

This intends to be deliberate about what needs to be done for different
DefaultValue types.  Some of the tests will still fail after this is added.
This is safe because the clone method on the trait type now correctly sets
up default values.
@corranwebster corranwebster marked this pull request as ready for review May 20, 2022 13:17
@mdickinson mdickinson self-requested a review May 20, 2022 14:21
Copy link
Member

@mdickinson mdickinson 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, and I strongly agree that getting rid of the specialization in has_traits.py and having the trait types be responsible for doing The Right Thing is the way to go. A few comments, mostly at nitpick level.

traits/tests/test_expression.py Show resolved Hide resolved
traits/tests/test_interfaces.py Show resolved Hide resolved
traits/trait_type.py Outdated Show resolved Hide resolved
traits/has_traits.py Show resolved Hide resolved
traits/trait_type.py Show resolved Hide resolved
traits/trait_type.py Outdated Show resolved Hide resolved
traits/trait_type.py Outdated Show resolved Hide resolved
traits/trait_type.py Outdated Show resolved Hide resolved
@corranwebster corranwebster self-assigned this Jul 11, 2022
@mdickinson
Copy link
Member

@corranwebster I think this is ready to go in. Any last thoughts before I merge?

@mdickinson mdickinson added component: core Issues related to the core library porting: needs backport to 6.4 This PR needs to be backported to the maint/6.4 branch labels Aug 10, 2022
@corranwebster
Copy link
Contributor Author

I'm good with the changes.

@mdickinson
Copy link
Member

I'm good with the changes.

Thanks! Merging.

@mdickinson mdickinson merged commit 7ecd065 into main Aug 10, 2022
@mdickinson mdickinson deleted the fix/trait-type-clone-defaults branch August 10, 2022 13:47
mdickinson pushed a commit that referenced this pull request Aug 10, 2022
This PR works towards a fix of #1630 and related issues.

The starting point is a set of regression tests that identify the behaviour which doesn't seem correct and test for the expected behaviour. This then adds changes to TraitTypes.clone that fix a number of the observed issues. We then remove the default value wrangling in HasTraits as it should no longer be needed.

I think at this point everything is in a better state than it was: we have less unexpected behaviour.

There may be subsequent things which might be advisable, such as raising warnings about future deprecation of certain behaviours, adding clone methods to particular trait types, etc.

Co-authored-by: Mark Dickinson <[email protected]>
(cherry picked from commit 7ecd065)
@mdickinson mdickinson removed the porting: needs backport to 6.4 This PR needs to be backported to the maint/6.4 branch label Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: core Issues related to the core library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants