pyment icon indicating copy to clipboard operation
pyment copied to clipboard

Trailing white space introduced

Open peterjc opened this issue 8 years ago • 4 comments

Tools like flake8 will complain about trailing white space (W291), and it seems pyment sometimes introduces white space.

As a specific example, take the test.py example from the README.rst file which produces the following:

        def func(param1=True, param2='default val'):
            """Description of func with docstring groups style.

            :param param1: descr of param1 that has True for default value
            :param param2: descr of param2 (Default value = 'default val')
            :returns: some value
            :raises keyError: raises key exception
	    :raises TypeError: raises type exception

	    """
            pass

        class A:
            """ """
            def method(self, param1, param2=None):
	        """

	        :param param1:
                :param param2:  (Default value = None)

	        """
                pass

There is a trailing space on the line :param param1: in the class A method, both here and in the patch itself.

I have confirmed this running pyments test.py locally using v0.3.2

Other examples (which I have not reduced to a minimal test case) introduce "blank lines" with the default indentation spaces included. I had a look at the code, but was confused by the multiply defined lambda function with_space which seems might be to blame.

peterjc avatar Sep 08 '17 15:09 peterjc

Hi @peterjc, It was intended to add a trailing space. It is to enjoin the user to edit the missing descriptions. Perhaps an option should allow to avoid this?

dadadel avatar Sep 26 '17 08:09 dadadel

I assumed this was a mistake, rather than at least some of these cases being deliberate.

Personally I avoid trailing white space (as per the flake8 defaults), so would prefer not to have trailing white space added. However, it is relatively easy to remove automatically (eg with sed).

peterjc avatar Sep 26 '17 10:09 peterjc

Perhaps adding an option allowing to insert or not the white space should be added.

dadadel avatar Sep 28 '17 10:09 dadadel

Even when I specify a config trailing_space= I still get trailing spaces after the param

def solution(name: str, age: int, gender: str = 'M') -> bool:
    """

    :param name: str:⚪
    :param age: int:⚪
    :param gender: str:  (Default value = 'M')

    """
    return True

S-Mann avatar Jul 15 '21 21:07 S-Mann