Deprecate the use of CHECK_INTERFACES for automatic interface checking. #1231
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[Builds on the commits in #1225; related to issue #1221, but doesn't completely resolve that issue]
Currently, if
has_traits.CHECK_INTERFACES
is nonzero, the@provides
decorator performs interface checking at the point where the class is decorated.This has a number of issues:
provides
happens at import time, so someone who wants to make use of this needs to be careful about import order, settinghas_traits.CHECK_INTERFACES
before the imports they want checked happenisinstance
check thatInstance(ISomeInterface)
now does at trait assignment time (pre Traits 6.0.0, it did match)has_traits.py
source, adding a circular dependency that has to be resolved via a local importLonger term, if we do interface checking we likely want to do it statically.
This PR deprecates the interface-checking behaviour of
provides
, and issues a deprecation warning for any use of@provides
with a nonzeroCHECK_INTERFACES
value. In a future Traits version (likely 7.0), we'd then remove the interface-checking call fromprovides
altogether.In a search of Traits-using code, I failed to find any code outside Traits that makes use of a non-zero
CHECK_INTERFACES
. I would expect the impact of this change to be negligible.Checklist
docs/source/traits_api_reference
) (Not relevant in this case)docs/source/traits_user_manual
)traits-stubs
(Not relevant in this case)