-
-
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
Hide Nursery constructor, finalize and expose Nursery #1090
Conversation
f458ba7
to
522fee5
Compare
Codecov Report
@@ Coverage Diff @@
## master #1090 +/- ##
==========================================
+ Coverage 99.54% 99.54% +<.01%
==========================================
Files 102 102
Lines 12501 12512 +11
Branches 950 950
==========================================
+ Hits 12444 12455 +11
Misses 36 36
Partials 21 21
|
522fee5
to
94fe041
Compare
We don't need to worry about special metaclasses for So far, This means that as it stands, this PR doesn't change anything in the public API – it takes something that was already hidden, and makes it even more hidden :-). But, it makes it possible to start exporting |
Oh, and there are quite a few other classes where we might want to use these metaclasses – #1044 is a placeholder for figuring that out. I'll comment there with more details. The actual change in this PR looks good. Going forward, I don't think we need to add this many tests every time we mark a class as |
Yes. I haven't used the init and all patterns for making symbols public before but seems straightforward enough. Unless we need a newsfragment or explicit test for the visibility of trio.Nursery. |
Yep, you got it.
We don't need a test, but a newsfragment would be good. We should also add it to the docs. The docs are more complicated than you might think, because we need to unwind the weird hack we're using to work around We put reference docs into docstrings on each class/function/method, using Google-style docstrings, and then in the sphinx manual we use the For nursery, because it's not a public class, we couldn't do this, so instead we have some awkward workarounds. If you look at
So it would be good to move these docs into docstrings, convert to Google docstring style, and then pull them in with |
Okay, I'll take a look at untangling the Nursery workaround. |
Okay, I understand what's going on with Nursery, but still figuring out the restructured text syntax. Notably Sphinx can't autoextract cancel_scope from the attribute list in the docstring because it's an instance variable and not a @Property. Feels like it should be document with the other attributes of Nursery though. |
Yes, sorry, I have more edits but I accidentally pushed my draft version. Is that a "draft" or "do not merge" label I should apply while I'm working on it? |
Github has some kind of official way to mark a PR as "draft status" now, but I don't know if you can set it from an open PR – the docs just describe how to set it when creating a new PR. The old convention is to edit the title to start with |
I think this is ready now. (And I learned a lot about Sphinx.) Note that Nursery didn't have an actual docstring before, so someone should scrutinize that. Not sure what's going on with the builds. Is Azure Pipelines having issues? |
The macOS failure is weird... might just be some kind of glitch? The Travis CHECK_DOCS failure is:
|
Let's see if the macOS failure is a glitch or not by closing/reopening. |
397dbbb
to
93e5ab8
Compare
93e5ab8
to
2840640
Compare
2840640
to
4d2f7af
Compare
Okay, I think I had some wires crossed after a rebase but I think this looks good now. |
Thank you! This looks really good: Ironically we're now emphasizing the However, one thing that changed that we can probably improve is that start_soon is now at the bottom, but that's the method you want to show first. Ideally we could show (@njsmith if you think none of that matters, please feel free to merge!) |
Oh yeah, good point. And actually, I think I figured out how to deemphasize this. If I just pushed this change |
Yeah, I just have to include the methods/attributes explicitly in the rst, I can do that. |
Nice find for the constructor! Another option is to reorder the sources themselves, but I guess that introduces churn. Anyway, that's minor, and can always refine this later, so I'll merge this. Thank you! |
Nice catch on the nursery constructor :-) |
Issue: #1021
Seemed like a doable first issue for me since I've dabbled in metaclasses (and they classes were already written.)
Applied NoPublicConstructor to Nursery and added test cases for instantiation and subclassing. Worked pretty easily. Don't know the codebase well enough to know what else we might want to privatize. NurseryManager? CancelStatus? Do we want to protect everything or are there certain classes that are too magic to exist in nature?