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

Black and docformatter don't agree on multiline string which starts with a " #2912

Open
thejcannon opened this issue Mar 7, 2022 · 7 comments
Labels
F: docstrings How we format docstrings T: style What do we want Blackened code to look like?

Comments

@thejcannon
Copy link
Contributor

Describe the style change

Given the following docstring, black shouldn't insert a leading space.

""""Cookie eaters" are the set of people that eat cookies."""

Examples in the current Black style

""" "Cookie eaters" are the set of people that eat cookies."""

Desired style

""""Cookie eaters" are the set of people that eat cookies."""

(Which is how docformatter leaves it)

Additional context

@thejcannon thejcannon added the T: style What do we want Blackened code to look like? label Mar 7, 2022
@JelleZijlstra
Copy link
Collaborator

We added the spacing on purpose to make the code clearer. Could docformatter change instead?

@JelleZijlstra JelleZijlstra added the F: strings Related to our handling of strings label Mar 7, 2022
@thejcannon
Copy link
Contributor Author

Perhaps, but I'd trust a tool dedicated to formatting docstrings's style over a tool for general Python code. Really the pain just comes from constant reformatting because of the conflict.

I did verify (on Python 3.8 at least) that the help with/without the space is equivalent. Likely a result of https://docs.python.org/3/library/inspect.html#inspect.cleandoc

@thejcannon
Copy link
Contributor Author

Looks like there's a standing issue: PyCQA/docformatter#39

@thejcannon
Copy link
Contributor Author

I also think I like the black style better. Just hate being in formatting limbo 🥴

@ghost
Copy link

ghost commented Apr 2, 2022

IMO if there's a space on the left side there should be one on the right side too, otherwise it looks inconsistent. But not having a space at all also looks weird.

@weibullguy
Copy link

I've been cleaning up the docformatter open issues and PRs. I just opened #94 to add an argument (e.g., --black) to allow both tools to behave themselves when used together. Poking around the black code, I see you're following PEP 257 for docstring indentation (which should be compatible already) in addition to the formatting @thejcannon pointed out. If there is any other docstring formatting black does, I'd appreciate it if you dropped a comment in the above referenced issue so I can address everything at once. TIA

@felix-hilden
Copy link
Collaborator

I agree that separating the quotes looks nicer. Since it's being fixed on their side, are we good to close this issue?

@felix-hilden felix-hilden added F: docstrings How we format docstrings and removed F: strings Related to our handling of strings labels Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: docstrings How we format docstrings T: style What do we want Blackened code to look like?
Projects
None yet
Development

No branches or pull requests

4 participants