Skip to content
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

Merged
merged 15 commits into from
Apr 21, 2018
Merged

Switch to using standalone Outcome library. #503

merged 15 commits into from
Apr 21, 2018

Conversation

Fuyukai
Copy link
Member

@Fuyukai Fuyukai commented Apr 17, 2018

Closes #494. Closes #505.

Not sure what to do about the Result object section in hazmat docs yet.

@codecov
Copy link

codecov bot commented Apr 18, 2018

Codecov Report

Merging #503 into master will decrease coverage by <.01%.
The diff coverage is 98.27%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
trio/_core/_traps.py 100% <ø> (ø) ⬆️
trio/hazmat.py 100% <ø> (ø) ⬆️
trio/_core/__init__.py 100% <ø> (ø) ⬆️
trio/_core/_io_kqueue.py 78.48% <100%> (+0.27%) ⬆️
trio/_core/tests/test_run.py 100% <100%> (ø) ⬆️
trio/_core/tests/test_local.py 100% <100%> (ø) ⬆️
trio/_core/_result.py 100% <100%> (ø) ⬆️
trio/_core/_run.py 100% <100%> (ø) ⬆️
trio/_threads.py 100% <100%> (ø) ⬆️
trio/tests/test_timeouts.py 100% <100%> (ø) ⬆️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 94d49f9...0cbed90. Read the comment docs.


"""
class Result(outcome.Outcome):
@deprecated(version="0.5.0", issue=494, instead="outcome.Outcome")
Copy link
Member

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.

Copy link
Member

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).

@njsmith
Copy link
Member

njsmith commented Apr 18, 2018

Not sure what to do about the Result object section in hazmat docs yet.

You can delete the documentation of the Result objects themselves, and update the docs as if we always used outcome. (So e.g. wait_task_rescheduled's docstring will need some changes.)

@Fuyukai
Copy link
Member Author

Fuyukai commented Apr 18, 2018

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.

@njsmith
Copy link
Member

njsmith commented Apr 18, 2018

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 :-/.

@smurfix
Copy link
Contributor

smurfix commented Apr 18, 2018

+1 on converting old changelog entries to literals. The link is dead, no sense in keeping it.

@Fuyukai
Copy link
Member Author

Fuyukai commented Apr 18, 2018

Shoutouts to jenkins for arbitrarily refusing to install dependencies sometimes

@Fuyukai
Copy link
Member Author

Fuyukai commented Apr 18, 2018

The build is failing because Travis hates me, I guess. Other than that, is all ready.

@njsmith
Copy link
Member

njsmith commented Apr 19, 2018

The build failure was sphinx trying to fetch the intersphinx inventories, and then failing with the gnomic error message:

Warning, treated as error:
failed to reach any of the inventories with the following issues:

Seems like some weird transient thing... I hope? I just restarted the job anyway.

@njsmith
Copy link
Member

njsmith commented Apr 19, 2018

Hmm. It failed again, while loading intersphinx inventory from https://outcome.readthedocs.org/objects.inv..., and indeed if I go to that URL I get a 404...

Maybe if you make the intersphinx link be https://outcome.readthedocs.io/en/latest/ it'll work better?

@njsmith
Copy link
Member

njsmith commented Apr 19, 2018

Also, @Fuyukai, @smurfix, can you figure out how #505 and this should be coordinated? outcome just merged python-trio/outcome#11, so if we merge this, and then release outcome, without first dealing with #505, then I think trio will be broken?

_deprecate.DeprecatedAttribute(
Error, "0.5.0", issue=494, instead="outcome.Error"
)
}
Copy link
Member

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.

@njsmith
Copy link
Member

njsmith commented Apr 19, 2018

So having read over the diff, I think the complete todo list is:

@Fuyukai
Copy link
Member Author

Fuyukai commented Apr 20, 2018

#505 was caused by The Curse of the Mutable Default. reschedule() had a default value for next_send of Value(None), which was being passed if there was no send - and promptly being unwrapped on the very first run loop. Then, when it was being yielded back up later on, it would be unwrapped again, and would explode.

@Fuyukai
Copy link
Member Author

Fuyukai commented Apr 20, 2018

Ready to merge.

Error, "0.5.0", issue=494, instead="outcome.Error"
)
}
Result.register(Error)
Copy link
Contributor

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?

Copy link
Member Author

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.

@njsmith
Copy link
Member

njsmith commented Apr 21, 2018

I filed #508 for the annoying jenkins failures, and once #509 is merged it might help us track them down.

- 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
@njsmith
Copy link
Member

njsmith commented Apr 21, 2018

Just made some small fixups – in particular, the deprecated attributes stuff was still a bit mixed up (see the commit message for ed0510a). LGTM now – @Fuyukai, want to review my changes and then hit merge if you like them?

(At least we got lucky on Jenkins this time...)

@Fuyukai Fuyukai merged commit c31b946 into python-trio:master Apr 21, 2018
@Fuyukai Fuyukai deleted the use-outcome branch May 5, 2018 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants