1

Some rules are used in more than a single situation. In particular, the rule C0326 is employed in at least 2 situations:

def func() : 
    pass

gives the message C0326:No space allowed before :

def func(param:int):
    pass

gives the message C0326:Exactly one space required after :

I want pylint to detect and complain about the first case, but not the second (yes, I know I'm a barbarian for not placing a space before the type hint) one. Since the code is the same but messages are different, I'm hopeful that it's possible to adjust these cases individually. Is it currently possible to do that?

drakenation
  • 382
  • 3
  • 15

1 Answers1

1

No, this isn't possible. Or rather, it's not possible without changing pylint's internals.

It may be that the easiest way to produce only the errors you want while still having barbaric whitespace practices would be to add a pylint-disabling comment on the relevant lines. As an example, consider the following sample file.

def fun(x) :  #pylint: disable=bad-whitespace
    return

def fun2(x:int):
    return 2 * x

Pylint will complain about the bad-whitespace in fun2, but not fun1.

davidlowryduda
  • 2,404
  • 1
  • 25
  • 29
  • I though about using the disable comment, but that would 1. pollute the code, since almost every function would have to have it and 2. disable the first case as well, which is something I don't want to. I guess I'll think about either opening an Issue in pylint's Issue Tracker or give up on my barbarians ways of whitespacing. – drakenation Jul 26 '18 at 06:17