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

Bug: formatting outside of docstring when first word is "default" #165

Closed
jamesbraza opened this issue Feb 21, 2023 · 5 comments · Fixed by #171
Closed

Bug: formatting outside of docstring when first word is "default" #165

jamesbraza opened this issue Feb 21, 2023 · 5 comments · Fixed by #171
Labels
S: duplicate Closed as a duplicate issue or PR

Comments

@jamesbraza
Copy link

Pretty niche bug here, docformatter is formatting outside of the docstring:

def foo():
    default = 0  # Comment

    def bar():
        pass

Running docformatter==1.5.1 on this:

> docformatter a.py
--- before/a.py
+++ after/a.py
@@ -1,5 +1,4 @@
 def foo():
     default = 0  # Comment
-
     def bar():
         pass
@github-actions github-actions bot added the fresh This is a new issue label Feb 21, 2023
@weibullguy weibullguy added S: duplicate Closed as a duplicate issue or PR and removed fresh This is a new issue labels Feb 22, 2023
@weibullguy
Copy link
Member

This is the same as the issue in #156 where the blank line is removed when there is a comment following the last line in a code block. Closing as a duplicate to #156.

@jamesbraza
Copy link
Author

Okay sounds good, didn't know they were the same issue.

@weibullguy one thing to note, is changing the variable name in the first line from default to something like ham, the issue goes away:

def foo():
    ham = 0  # Comment

    def bar():
        pass

docformatter seems to be matching the variable name, if that helps

@weibullguy
Copy link
Member

@jamesbraza Thanks for the additional information. It's weird behavior for sure 😕 But all the information I can get is helpful.

@weibullguy
Copy link
Member

@jamesbraza tag v1.6.1-rc1 should have the fix you need if you're interested in giving it a try before I officially release v1.6.1.

@jamesbraza
Copy link
Author

I wasn't sure how to pip install the v1.6.1-rc1, I tried pip install --pre and got nothing. I went ahead git clone'd the repo, and confirmed that this issue is resolved with the current master commit f1b0fa688a.

Nice job, thank you! ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S: duplicate Closed as a duplicate issue or PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants