PyCQA / docformatter

Formats docstrings to follow PEP 257
https://pypi.python.org/pypi/docformatter
MIT License
524 stars 61 forks source link

`Docformatter` conflict with `isort` #203

Closed M1troll closed 1 year ago

M1troll commented 1 year ago

Hi!

Description

I recently update docformatter v1.6.0 -> v1.6.4 and actions on my project was failed. After spending time searching, reason turned out to be following - isort and docformatter make opposite changes to the file:

Also was checked v1.6.1, v1.6.2 and v1.6.3 - they have same problem.

As I see it, PEP8 says:

You should put a blank line between each group of imports.

I think this applies to constants as well, so docformatter shouldn't remove that line.

Reproduction

You can reproduce my problem with next data:

Python code:

import os
from typing import Iterator

"""Don't remove this comment, it's cool."""
IMPORTANT_CONSTANT = "potato"

.pre-commit-config.yaml:

repos:
  - repo: https://github.com/pycqa/docformatter
    rev: v1.6.4
    hooks:
      - id: docformatter
        args: [
          --wrap-summaries=120,
          --wrap-descriptions=0,
          --in-place,
          --blank
        ]

  - repo: https://github.com/pycqa/isort
    rev: 5.12.0
    hooks:
      - id: isort

After run pre-commit run --all-files you will see that file changed twice and actions was failed:

import os
from typing import Iterator
-                                                                           
"""Don't remove this comment, it's cool."""
IMPORTANT_CONSTANT = "potato"
import os
from typing import Iterator
+                                                                           
"""Don't remove this comment, it's cool."""
IMPORTANT_CONSTANT = "potato"
weibullguy commented 1 year ago

@M1troll should be fixed in v1.6.5.

M1troll commented 1 year ago

@weibullguy , Thank you! Now everything works without problems)