Deprecate CHECK_INTERFACES and old-style interface checking
- Dominant language
- Python
- Stars
- 462
- Forks
- 90
- PR merge metrics
- No merged PRs in 30d
Description
I propose that we deprecate the old-style interface-checking machinery in Traits 7.0. Going forward, the recommendation should be that we use the standard library `abc`-based machinery.
One key difference is that the old-style interface checks check every single method, as opposed to just those decorated with `abstractmethod`. We should prefer the explicit, standard solution.
(Note that there's a lot of history here: the old-style stuff predated the introduction of the `abc` module in Python 3.0 / Python 2.6; over time since then, we've been slowly neutering the interface-checking so that it's less intrusive - for example, making the default for `CHECK_INTERFACES` equal to `0`, and removing the interface checking on assignment to a trait with trait type `Instance(MyInterface)`.)
There's more discussion and more fleshing out of details needed here. In particular, I'd like to keep the `Interface` type, but once we remove the old-style interface checking it'll become more-or-less a synonym for `ABCHasTraits`. It's still a nice name to indicate "this is a class that we intend to use as an interface - i.e., by registration, rather than by subclassing".
We'd also need to decide what to do about `provides`. Without the interface checking, it provides essentially the same functionality as `register`, in slightly different form. (But only slightly different. In Python 2, it used to be true that you couldn't use `register` as a decorator, but that restriction is gone in Python 3.)
Related: #1217.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing the existing CHECK_INTERFACES and Interface behavior, then read the discussion in related issue #1217. Resolve how Interface should relate to ABCHasTraits and what should replace provides; done means the old-style checking is deprecated with those design decisions documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100