You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
flake8 would check for whitespace and lines >80 (both not caught by black in examples); currently flake8 is only used for pygmt, setup.py, and doc/conf.py.
Perhaps docformatter should remove the trailing whitespace? It says:
docformatter also handles some of the PEP 8 conventions.
Don't write string literals that rely on significant trailing whitespace. Such trailing whitespace is visually indistinguishable and some editors (or more recently, reindent.py) will trim them.
docformatter can remove trailing whitespaces from the following script:
"""
A docstring with some invisible whitespace.
More description with some invisible trailing whitespaces.
"""
but does nothing to:
"""
A docstring with some invisible whitespace.
=================================================
More description with some invisible trailing whitespaces.
"""
docformatter can remove trailing whitespaces from the following script:
"""
A docstring with some invisible whitespace.
More description with some invisible trailing whitespaces.
"""
but does nothing to:
"""
A docstring with some invisible whitespace.
=================================================
More description with some invisible trailing whitespaces.
"""
Trailing spaces in docstrings sometimes have syntactical meaning (e.g., forcing a markdown line break). As questionable as it is to have some count of non-printing characters trigger a material document change, we are where we are (and Markdown is extremely prevalent). Stripping those trailing spaces in docstrings could break the formatting of parameter lists in IDE code hints (and probably some other stuff I haven't thought of).
I'm going to close the issue mainly because: (1) it's a minor issue, (2) it does't bother us in the last two years, (3) modern text editors and IDEs have configurations to do it automatically.
Activity
seisman commentedon Feb 19, 2021
I tried the following script (with invisible trailing whitespaces in many lines):
Running
blackremoves all trailing whitespaces for me.Not sure why it hehaves differently in #890.
seisman commentedon Feb 19, 2021
No,
blackdoesn't remove the trailing whitespace in the docstrings of the file.maxrjones commentedon Feb 19, 2021
flake8would check for whitespace and lines >80 (both not caught byblackin examples); currentlyflake8is only used for pygmt, setup.py, and doc/conf.py.weiji14 commentedon Feb 19, 2021
Does
blackdocnot remove the trailing whitespace in the docstrings? Interesting 🤔 Might be worth filing an issue on https://github.com/keewis/blackdoc if we can confirm this.seisman commentedon Feb 19, 2021
None of
black,blackdoc, anddocformatterdoes to the file-scope docstrings. It's possible these are not "docstrings" https://www.python.org/dev/peps/pep-0257/.seisman commentedon Feb 20, 2021
Related issue: psf/black#318
michaelgrund commentedon Feb 20, 2021
Means it is not possible to do any automatic check and everybody has to care about the spaces before committing, right?
seisman commentedon Feb 20, 2021
Perhaps docformatter should remove the trailing whitespace? It says:
seisman commentedon Feb 20, 2021
docformattercan remove trailing whitespaces from the following script:but does nothing to:
Reported a bug to
docformatterat PyCQA/docformatter#71.michaelgrund commentedon Feb 23, 2021
Interesting but good to know that we can differentiate between normal scripts and sphinx-gallery style header docstrings.
seisman commentedon Jun 7, 2022
Perhaps we should try https://github.com/DanielNoord/pydocstringformatter.
brnt commentedon May 28, 2023
Trailing spaces in docstrings sometimes have syntactical meaning (e.g., forcing a markdown line break). As questionable as it is to have some count of non-printing characters trigger a material document change, we are where we are (and Markdown is extremely prevalent). Stripping those trailing spaces in docstrings could break the formatting of parameter lists in IDE code hints (and probably some other stuff I haven't thought of).
seisman commentedon Nov 23, 2023
I'm going to close the issue mainly because: (1) it's a minor issue, (2) it does't bother us in the last two years, (3) modern text editors and IDEs have configurations to do it automatically.