Repository navigation
Move towards making most public classes Final - #1501
Merged
Merged
Conversation
These have never had a usable public constructor, so we might as well use the annotation so in case anyone tries they'll get a nice error message.
For when we want to switch to Final, but with a deprecation period first.
Codecov Report
@@ Coverage Diff @@
## master #1501 +/- ##
=======================================
Coverage 99.67% 99.67%
=======================================
Files 107 107
Lines 13202 13244 +42
Branches 995 1006 +11
=======================================
+ Hits 13159 13201 +42
Misses 28 28
Partials 15 15
|
auvipy
approved these changes
May 8, 2020
pquentin
reviewed
May 8, 2020
| changes for fear of breaking subclasses. | ||
|
|
||
| There are also some classes that were explicitly designed to be | ||
| subclassed, like the ones in `trio.abc`. Subclassing these is still |
Member
There was a problem hiding this comment.
For what it's worth, the docs check is failing with /home/runner/work/trio/trio/docs/source/history.rst:37:py:obj reference target not found: trio.abc
Member
Author
There was a problem hiding this comment.
Ah, whoops, thanks for the heads up! I forgot we don't have a dedicated page for trio.abc.
pquentin
approved these changes
May 8, 2020
oremanj
reviewed
May 8, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This changes most of Trio's public classes so that attempts to
subclass them will produce a deprecation warning, with the idea that
once the deprecation period passes on we'll use metaclass=Final to
make subclassing an error.
See #1104 for discussion.
There are some special cases where we do allow subclassing: ABCs,
exceptions, enums, etc. I also added a test to make sure that every
public class is either Final, on its way to becoming Final, or else
falls into one of the special cases. The idea is that when we add new
classes in the future, this will force us to either mark them Final,
or else add a new special case, hopefully with a comment explaining
what makes the new class a special case.