keewis/blackdoc

multiple semicolon separated commands are not handled well

Closed this issue · 4 comments

>>> print("----");print(anon_browser.contents)

gets turned into

>>> print("----")
... print(anon_browser.contents)

When I then tried to run the doctests I got a

SyntaxError: multiple statements found while compiling a single statement

this is not actually hard to do (and even easier after #144). However, we'd need to analyze the AST to implement it, which up until now was left entirely to black. Let me see what I can do.

@keewis For now, as a workaround, I converted the above statements into a single one.

-    >>> print("----")
--
+    >>> print("----\n%s" % anon_browser.contents)

this will be fixed in the next version, but you could also just pass both to a single print call:

>>> print("----", anon_browser.contents, sep="\n")

which is probably better, given that splitting the print calls into separate doctest lines makes the ---- a bit pointless?

Indeed. 👍