-
Notifications
You must be signed in to change notification settings - Fork 68
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
Add argument to tell docformatter to be compatible with black #94
Comments
Other than PEP 257, we occasionally move quotes. I'm not entirely sure when Black does move quotes, but it's pretty rare and it's probably more an edge case than codified behaviour. For more see psf/black#1632 and psf/black#3044. For posterity, here what the documentation has to say on docstrings:
https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#strings cc @JelleZijlstra am I forgetting another way we format docstrings? |
Should this be closed by #46? |
Maybe we can start by adding an entry for Now I would love to have a dedicated
As for the never-ending loop, I addressed it by running |
@thejcannon I don't think so. #46 adds a space before the summary regardless of what the first character in the summary is. Black only adds the space if the first character is a double quote Currently @kdeldycke here is a snippet from my docformatter "road map" notes:
|
Thanks @weibullguy for comparing notes about the details of black-compatible options. You just confirmed my initial findings! :) |
Having just run into the incompatibility between black and docformatter 1.6, I'm really happy to see the work being done here. The suggestions that @weibullguy added are great, but I would also like to point out that black has configurable line length and other options. Should a black compatible docformatter inherit those black config options from the pyproject.toml, or should the user need to manually match the config options? |
Put an attempt to address this issue above, hoping to get feedback on if its on the right track before finishing it |
Other than line length, what other black options would docformatter need to accommodate? |
I've provided some feedback in the PR. |
@weibullguy Line length is the only thing I know of that is problematic. |
For the latest version (v1.6.0-rc5), docformatter removes whitelines after block comments.
After applying Docformatter:
DocFormatter version v1.5.1 seems to be the latest version that keeps the empty lines, keeping it compatible with black. |
@gerbenoostra that is correct. Per PEP-257, |
I see I have another tool interfering. I also use |
@NickHilton take a look at the |
Will take a look - Just pushed the other changes for #166 which I'm hoping make all the unittests pass for the behaviour other than this blank line thing. Will hopefully get to look at that by Wednesday |
As pointed out in #39, black inserts a space before a one-line or the summary in a multi-line docstring when it begins with a quote (") character. Default behavior for docformatter is to remove this space, which leads to a never-ending loop. The newly created argument
--pre-summary-space
will retain this black-inserted space at the expense of adding a space before every docstring, which black will then remove resulting in, yet again, a never-ending loop.Add an argument (e.g.,
--black
) to make docformatter only add the space when the line begins with a quote character when the--pre-summary-space
argument is set. Thus, the invocation for black compatibility would be:The text was updated successfully, but these errors were encountered: