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

Docstrings containing backticks are not formatted #243

Closed
paduszyk opened this issue Jun 26, 2023 · 1 comment Β· Fixed by #248
Closed

Docstrings containing backticks are not formatted #243

paduszyk opened this issue Jun 26, 2023 · 1 comment Β· Fixed by #248
Labels
C: convention Relates to docstring format convention P: bug PEP 257 violation or existing functionality that doesn't work as documented U: high

Comments

@paduszyk
Copy link

Hi! βœ‹πŸ»

The package is great! Thanks a lot for contributing! πŸ₯‡

I have been using it for while and recently noticed that the tool ignores the docstrings containing "backticks" (the ones used e.g. to markup inline code in GitHub markdown).

My configuration (pyproject.toml) is:

[tool.docformatter]
black = true
blank = true
close-quotes-on-newline = true
make-summary-multi-line = true
recursive = true
pre-summary-newline = true

Sample code:

def foo(bar):
    """Return `foo` using `bar`. Description."""

is not formatted (neither via CLI nor pre-commit hook). If I replace backticks to single quotation marks, everything works as expected, namely I get the following diff.:

--- before/./test.py
+++ after/./test.py
@@ -12,4 +12,9 @@
 
 
 def foo(bar):
-    """Return 'foo' using 'bar'. Description."""
+    """
+    Return 'foo' using 'bar'.
+
+    Description.
+
+    """

Any ideas? Thanks! 🀝

@github-actions github-actions bot added the fresh This is a new issue label Jun 26, 2023
@weibullguy weibullguy added P: bug PEP 257 violation or existing functionality that doesn't work as documented C: convention Relates to docstring format convention and removed fresh This is a new issue labels Jun 27, 2023
@paduszyk paduszyk changed the title Docstring containing backticks are not formatted Docstrings containing backticks are not formatted Jun 28, 2023
@maddenp-noaa
Copy link

I have

% docformatter --version
docformatter 1.7.5

The fix appears to apply only to the first line and not to the description lines that follow, e.g.

% cat foo.py
def f():
    """
    Here is a sufficiently long docstring first line with a ``word`` wrapped in backticks which will be wrapped as expected.

    Here is a sufficiently long docstring description with a ``word`` wrapped in backticks which will not be wrapped as expected.
    """
    pass
% docformatter foo.py
% cat foo.py
def f():
    """
    Here is a sufficiently long docstring first line with a ``word`` wrapped in backticks which will
    be wrapped as expected.

    Here is a sufficiently long docstring description with a ``word`` wrapped in backticks which will not be wrapped as expected.
    """
    pass

Is this intended / am I doing it wrong?

Here's my config block in pyproject.toml:

[tool.docformatter]
black = true
in-place = true
make-summary-multi-line = true
pre-summary-newline = true
recursive = true
wrap-descriptions = 100
wrap-summaries = 100

Thanks in advance for any guidance, and thanks in general for this great tool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: convention Relates to docstring format convention P: bug PEP 257 violation or existing functionality that doesn't work as documented U: high
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants