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

don't remove the trailing newline for blocks #52

Closed
keewis opened this issue Oct 26, 2020 · 0 comments · Fixed by #62
Closed

don't remove the trailing newline for blocks #52

keewis opened this issue Oct 26, 2020 · 0 comments · Fixed by #62

Comments

@keewis
Copy link
Owner

keewis commented Oct 26, 2020

To continue from pydata/xarray#4510 (comment):

I agree that if possible it would be good to keep the newline at the end of a block. Actually, I think doctests are just copied lines from the standard python REPL, so they should be as close to that as possible.

Consider this:

>>> 1 + 2
...

I would like to have blackdoc collapse that to a single line since it's impossible to get multiple lines in the REPL unless the line contains more opening that closing brackets or parens, or if it is the opening line of a block.

Thinking about this some more, maybe it's enough to check whether the first line of the code block matches

[^:]+:(\s+#.*)?

there are still a few corner cases this wouldn't match, though (lambda definitions, for example)

Edit: I can't seem to be able to get black to split the lambda definition after the colon, so I'll wait for bug reports before trying to modify the regular expression.

cc @max-sixty

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 a pull request may close this issue.

1 participant