-
-
Notifications
You must be signed in to change notification settings - Fork 348
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
Switch to using standalone Outcome library. #503
Conversation
Codecov Report
@@ Coverage Diff @@
## master #503 +/- ##
==========================================
- Coverage 99.27% 99.26% -0.01%
==========================================
Files 89 89
Lines 10418 10405 -13
Branches 720 721 +1
==========================================
- Hits 10342 10329 -13
Misses 58 58
Partials 18 18
Continue to review full report at Codecov.
|
trio/_core/_result.py
Outdated
|
||
""" | ||
class Result(outcome.Outcome): | ||
@deprecated(version="0.5.0", issue=494, instead="outcome.Outcome") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Result
was previously an ABC, so I wouldn't expect anyone to be trying to construct it; I think the deprecation notice would need to go on capture(), acapture(), and the constructors of Value and Error in order to have any effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Value
and Error
I'd suggest using trio._deprecate
's trick for module level deprecations. It lets you say "when someone accesses trio.hazmat.Value
, then give them [this] deprecation message and then return [this] object." It looks like the diff for 089c6ff has an example.
It might even be simplest to use this for Result
too. The advantage is that it gives a warning for isinstance(x, trio.hazmat.Result)
.
You can delete the documentation of the |
So, this conf.py nitpicky thing isn't very sustainable since we have to add every deprecated item there as it's in the changelog by a reference still. |
I think it would also be fine to convert the old changelog links into regular literal strings, if that's easier? (I know it feels weird to edit old changelogs, but it's just a formatting tweak, not a content change.) Unfortunately without the nitpicky thing it's very very easy to have broken links all over the place :-/. |
+1 on converting old changelog entries to literals. The link is dead, no sense in keeping it. |
Shoutouts to jenkins for arbitrarily refusing to install dependencies sometimes |
The build is failing because Travis hates me, I guess. Other than that, is all ready. |
The build failure was sphinx trying to fetch the intersphinx inventories, and then failing with the gnomic error message:
Seems like some weird transient thing... I hope? I just restarted the job anyway. |
Hmm. It failed again, while Maybe if you make the intersphinx link be |
Also, @Fuyukai, @smurfix, can you figure out how #505 and this should be coordinated? |
trio/_core/_result.py
Outdated
_deprecate.DeprecatedAttribute( | ||
Error, "0.5.0", issue=494, instead="outcome.Error" | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, this __deprecated_attributes__
thing is pretty confusing, we need some better docs here...
Since it's based on module attribute lookup, using this inside trio._core._result
means that we'll issue warnings when someone mentions trio._core._result.<whatever>
, which isn't really what we want – it's references to trio.hazmat.<whatever>
that people might doing and we want to deprecate. So we want to apply the __deprecated_attributes__
stuff to trio.hazmat
. In the version we used to have here we did that in trio/__init__.py
, which seems as good as anything: 089c6ff#diff-9bcb0dac3a23179589f66a8646fa38faL107
Also, this isn't really relevant because of the previous issue, but as an FYI: I think this also wouldn't work because the __deprecated_attributes__
stuff is only checked if there isn't a real variable of the same name. (This is an optimization to avoid slowdowns on accessing non-deprecated attributes; it works using __getattr__
.) So here where are actual variables named Value
, Error
, Result
in the same module, it makes __deprecated_attributes__
a no-op.
So having read over the diff, I think the complete todo list is:
|
#505 was caused by The Curse of the Mutable Default. |
Ready to merge. |
trio/_core/_result.py
Outdated
Error, "0.5.0", issue=494, instead="outcome.Error" | ||
) | ||
} | ||
Result.register(Error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh. Could you please keep the newline?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, missed that. Surprised yapf didn't catch it.
- The dict needs to live in the module where the deprecated attributes are; so here it needs to be hazmat.__deprecated_attributes__. (Maybe it would be less confusing to put this in hazmat.py, I don't know.) - Don't export the symbols from trio.hazmat using normal mechanisms; that overrides the __deprecated_attributes__ mechanism. - Then since they're no longer in hazmat, we can't say that trio.hazmat.Value resolves to the value trio.hazmat.Value, so point the __deprecated_attributes__ entries directly at trio._core._result.* - In fact, let's stop exporting them from trio._core entirely. - And then this reveals two tests that were still referring to trio._core.Error, so fix those. Confirmed manually that with these changes I get correct values and warnings for accessing the public attributes: In [2]: trio.hazmat.Result /home/njs/.user-python3.5-64bit/bin/ipython:1: TrioDeprecationWarning: trio.hazmat.Result is deprecated since Trio 0.5.0; use outcome.Outcome instead (#494) #!/home/njs/.user-python3.5-64bit/bin/python3.5 Out[2]: trio._core._result.Result # class In [3]: trio.hazmat.Value /home/njs/.user-python3.5-64bit/bin/ipython:1: TrioDeprecationWarning: trio.hazmat.Value is deprecated since Trio 0.5.0; use outcome.Value instead (#494) #!/home/njs/.user-python3.5-64bit/bin/python3.5 Out[3]: outcome.Value # class In [4]: trio.hazmat.Error /home/njs/.user-python3.5-64bit/bin/ipython:1: TrioDeprecationWarning: trio.hazmat.Error is deprecated since Trio 0.5.0; use outcome.Error instead (#494) #!/home/njs/.user-python3.5-64bit/bin/python3.5 Out[4]: outcome.Error # class
Closes #494. Closes #505.
Not sure what to do about the Result object section in hazmat docs yet.