-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Support non-multiple and non-named values in Yields and Receives #322
Conversation
Concerning code style, I come from a EDIT: nevermind, your CI setup told me where to find the config settings, and what linting errors to fix. |
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.
Thanks a lot! I appreciate the effort on splitting commits to ease review 🙂
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.
Thanks for the update.
Honestly I feel like the "aspect" check is overkill, I'd just prefer we remove it as well as the enum 🙂
GitHub doesn't seem to recognize a PR that has been reset to an earlier, already-reviewed state as already reviewed… Also, there's an apparently unrelated, failing CI test on Py3.13/Ubuntu-lowest-direct that's been haunting this PR since its inception. |
Don't mind the 3.13-lowest failure, it's unrelated indeed and it's allowed to fail. |
Just saw this, sorry. There's a |
Erm sorry I pushed a dirty commit. Let me rebase locally and force-push then merge. |
…s parsing The Returns, Yields and Receives section parsers only really differ in their fallbacks and the names of their configuration settings, not so much in their general parsing behavior and the expected formatting of the section contents. This commit is an attempt to factor out the following functionality: * Read the section contents as a single block, or as multiple blocks, depending on the `multiple` setting. * Parse each block's first line as a named parameter, or an unnamed parameter, depending on the `named` setting. * Unpack `Generator` and `Iterator` types in the return annotation. Optionally error out if the return annotation is not of these types. * Optionally destructure the return tuple if `multiple` is in effect. Issue-263: #263
Thanks again! |
…s annotation from parents Follow-up-of-PR-322: #322
I refactored the logic again in a80bd3c, I think it's even more readable now. |
That's fine. I wasn't sure if I should touch the "where is the annotation looked up in?" part, so my version doesn't quite reap the same readability benefits as yours. |
This PR fixes #263 by applying the same logic from the
Returns
section parser to theYields
andReceives
parser. TheYields
section parser is configured with the same two configuration variablesreturns_multiple_items
andreturns_named_value
, whereas theReceives
section parser is configured via the newreceives_multiple_items
andreceives_named_value
configuration variables. Furthermore, the parsing of multiple or single docstring block contents, of named or unnamed parameters, and the unpacking of generator and/or tuple return annotations has been refactored into separate functions.Contents:
Yields
andReceives
section parsers, essentially via copy-and-paste. Includes suitable tests, based on theReturns
section tests.