PyCQA / docformatter

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

Inconsistent behavior with :arg syntax #264

Open avylove opened 1 year ago

avylove commented 1 year ago

Seeing some inconsistent behavior in docformatter 1.7.5.

Docformatter 1.7.5 (Last successful CI used 1.7.3) CPython 3.11 Example file: https://github.com/jquast/blessed/blob/a34c6b1869b4dd467c6d1ab6895872bb72db7e0f/blessed/terminal.py

Docformatter flags the following

    def rgb_downconvert(self, red, green, blue):
        """
        Translate an RGB color to a color code of the terminal's color depth.

        :arg int red: RGB value of Red (0-255).
        :arg int green: RGB value of Green (0-255).
        :arg int blue: RGB value of Blue (0-255).
        :rtype: int
        :returns: Color code of downconverted RGB color
        """

Allowing Docformatter to fix it results in all the arguments running together

    def rgb_downconvert(self, red, green, blue):
        """
        Translate an RGB color to a color code of the terminal's color depth.

        :arg int red: RGB value of Red (0-255). :arg int green: RGB value of Green (0-255). :arg int
        blue: RGB value of Blue (0-255).
        :rtype: int
        :returns: Color code of downconverted RGB color
        """

Changing arg to param prevents it from being flagged

   def rgb_downconvert(self, red, green, blue):
        """
        Translate an RGB color to a color code of the terminal's color depth.

        :param int red: RGB value of Red (0-255).
        :param int green: RGB value of Green (0-255).
        :param int blue: RGB value of Blue (0-255).
        :rtype: int
        :returns: Color code of downconverted RGB color
        """

However, arg is not flagged elsewhere in the file and is processed fine with autodoc

    def move_yx(self, y, x):
        """
        A callable string that moves the cursor to the given ``(y, x)`` screen coordinates.

        :arg int y: vertical position, from top, *0*, to bottom of screen, *self.height - 1*.
        :arg int x: horizontal position, from left, *0*, to right edge of screen, *self.width - 1*.
        :rtype: ParameterizingString
        :returns: Callable string that moves the cursor to the given coordinates
        """
pedropaulofb commented 10 months ago

I am facing a similar situation, as I reported on the issue #271. The problem started on version 1.7.4.