Use standalone result library instead #494
Comments
CC @RazerM There may be a small bit of awkwardness here because class Result(Outcome):
@classmethod
def capture(...):
...
@classmethod(...)
async def acapture(...):
...
Result.register(Outcome) # yes, they're subclasses of each other, what's wrong with that? Gross hacks are fine because it's just a temporary shim that we'll throw away in a few versions after the deprecation period... |
@njsmith We'll have a problem there from https://github.com/python/cpython/blob/1672c2fbae6128ee4717e08c4e65a0ab99a02a02/Lib/abc.py#L162-L164 |
Bah, fine. I bet CPython isn't any fun at parties either. In this case I think it would be enough to register just the concrete classes |
The issue with this is that I cannot see a way to meet all of the following:
If the first point is lifted, it can simply be Value = outcome.Value / Error = outcome.Error and register them as virtual subclasses of Result. |
Oh, you mean because right now someone could write |
- 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 (python-trio#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 (python-trio#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 (python-trio#494) #!/home/njs/.user-python3.5-64bit/bin/python3.5 Out[4]: outcome.Error # class
As said in #477, the Result objects got split out into a separate library (https://github.com/python-trio/outcome). There's no point duplicating all the code in Trio - better to depend on it directly.
Todo:
outcome
instead.Maybe make the current objects in Trio simply redirect to the outcome objects until the next version, deprecating them in 0.5 (with a redirect) and removing in 0.6.
The text was updated successfully, but these errors were encountered: