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

Major change in 1.5.1 removes empty lines after class definitions #139

Closed
rixx opened this issue Dec 19, 2022 · 1 comment · Fixed by #142
Closed

Major change in 1.5.1 removes empty lines after class definitions #139

rixx opened this issue Dec 19, 2022 · 1 comment · Fixed by #142
Labels
C: convention Relates to docstring format convention P: bug PEP 257 violation or existing functionality that doesn't work as documented S: merged Closed with work merged to repository
Milestone

Comments

@rixx
Copy link

rixx commented Dec 19, 2022

I updated to docformatter 1.5.1 from 1.5.0 expecting no major changes to take place. However, I found that running docformatter removes all empty lines following class definitions, even when there is no docstring present.

I'm not sure if this is intentional, but I expected docformatter to only modify places where there is a docstring present.

(I ran into this face-first because Django generates its migration files with an empty line after class definition, so a patch version upgrade resulted in 171 files changed, 113 insertions(+), 286 deletions(-) for me. Half of that is this issue, the other half that apparently the max line length was slightly shortened?)

Reproduction:

Format this file with docformatter==1.5.0 and docformatter==1.5.1:

class Test:

    default = True

1.5.0 will leave the file alone, while 1.5.1 will output

--- before/test.py
+++ after/test.py
@@ -1,3 +1,2 @@
 class Test:
-
     default = True

This change appears to be related to #130.

@github-actions github-actions bot added the fresh This is a new issue label Dec 19, 2022
rixx added a commit to pretalx/pretalx that referenced this issue Dec 19, 2022
docformatter changes default line length and behaviour outside of
docstrings in a patch release. I'm probably too used to the utter
commitment to stability that is black, but keeping docformatter around
is not worth the maintenance effort like this. Will revert if they
commit to stronger stability guarantees. Ref PyCQA/docformatter#139
@weibullguy weibullguy added P: bug PEP 257 violation or existing functionality that doesn't work as documented C: convention Relates to docstring format convention V: patch Bumps the patch version and removed fresh This is a new issue labels Dec 19, 2022
@weibullguy weibullguy added this to the v1.6.0 milestone Dec 21, 2022
@weibullguy weibullguy added the S: merged Closed with work merged to repository label Dec 29, 2022
@weibullguy
Copy link
Member

docformatter now has a method to determine whether blank lines after a class definition precede a docstring. If so, the blank lines are removed. If not, they are left alone.

Thanks @rixx for reporting the issue. Sorry for the headaches it caused.

@weibullguy weibullguy removed the V: patch Bumps the patch version label Jan 19, 2023
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 S: merged Closed with work merged to repository
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants