-
Notifications
You must be signed in to change notification settings - Fork 4
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
doctest
command continuation and chained methods
#173
Comments
The reason
For new code I'd use parens: they don't have the issues - >>> g=[8,2,3]
- >>> (sorted(g)
- ... .long_method_name1()
- ... .long_method_name2()
- ... .long_method_name3()
- ... .long_method_name4()
- ... .long_method_name5())
+ >>> g = [8, 2, 3]
+ >>> (
+ ... sorted(g)
+ ... .long_method_name1()
+ ... .long_method_name2()
+ ... .long_method_name3()
+ ... .long_method_name4()
+ ... .long_method_name5()
+ ... )
8
""" |
I'm having a problem with a doctest in one of my repos. We have some doctests where methods are chained, and they are written across multiple lines using the "command continuation" format. But I seem to have trouble getting both
doctest
andblackdoc
to work simultaneously.This example is trivial, but I think shows the problem:
do_things
works as adoctest
, but it fails to parse inblackdoc
:error: cannot format /private/tmp/testing/test.py: Cannot parse: 12:0: EOF in multi-line statement
do_things_differently
also works as adoctest
, but fails to parse inblackdoc
:error: cannot format /private/tmp/testing/test.py: Cannot parse: 28:9: sorted(g) \\
do_other_things
parses inblackdoc
(and it suggests collapsing lines 44-45 into 1 line), but does not parse as adoctest
:do_that
parses correctly inblackdoc
, but gives the wrong answer indoctest
:Obviously in this case we could just put everything on one line, but in general in our repo we'd to have it chained, on multiple lines. Is there a way to format this that I'm not seeing?
OS: MacOS 13.2.1
Python: 3.10.10
Blackdoc: 0.3.8
Thanks for your help.
The text was updated successfully, but these errors were encountered: