How to disable in Pylint "Not allowed space around the assignment of keywords"?

How to disable Pylint's "Prevent Spaces in Assigning Keyword Arguments"?

I found why it checks for spaces ( PEP 8, why there are no spaces around the "=" in the keyword argument or the default parameter value? ), But I disagree because it means I need to spend hours resolving just this message .

I was looking for a message, so I can disable it in rcfile here: http://pylint-messages.wikidot.com/all-codes But the message does not appear in the pylint documentation ?!

+5
source share
1 answer

Disabling in Pylint

This can be disabled in Pylint using bad-whitespace :

 $ cat a.py myfunca(myargb = 3) $ pylint a.py --reports=n No config file found, using default configuration ************* Module a C: 1, 0: No space allowed around keyword argument assignment myfunca(myargb = 3) ^ (bad-whitespace) C: 1, 0: Missing module docstring (missing-docstring) E: 1, 0: Undefined variable 'myfunca' (undefined-variable) $ pylint a.py --disable bad-whitespace --reports=n No config file found, using default configuration ************* Module a C: 1, 0: Missing module docstring (missing-docstring) E: 1, 0: Undefined variable 'myfunca' (undefined-variable) 

Disable in PEP8 Checker

For completeness, you can disable the same for pep8 checker using E251 :

 $ pep8 a.py a.py:1:15: E251 unexpected spaces around keyword / parameter equals a.py:1:17: E251 unexpected spaces around keyword / parameter equals $ pep8 a.py --ignore=E251 

Update - information about suppressing only this message

AFAIK, you can disable messages only until the identifiers are detailed in pylint, since all spaces have the same bad-whitespace aka C0326 so you can ignore all or nothing.

This is the code that checks if the message is disabled, since you see that it receives only the identifier that needs to be checked:

 def is_message_enabled(self, msg_descr, line=None, confidence=None): """return true if the message associated to the given message id is enabled msgid may be either a numeric or symbolic message id. """ 

When a message is added to the lint results , you can see that bad-whitespace is all that is transmitted. The environment and purpose of the keyword arguments are just arguments for the message.

 warnings = [] if not any(good_space) and policies[0] == policies[1]: warnings.append((policies[0], 'around')) else: for ok, policy, position in zip(good_space, policies, ('before', 'after')): if not ok: warnings.append((policy, position)) for policy, position in warnings: construct = _name_construct(token) count, state = _policy_string(policy) self.add_message('bad-whitespace', line=token[2][0], args=(count, state, position, construct, _underline_token(token))) 

The arguments to the message are displayed using the line:

 'C0326': ('%s space %s %s %s\n%s', 'bad-whitespace', ('Used when a wrong number of spaces is used around an operator, ' 'bracket or block opener.'), 

All that should help if you want to configure pylint to do what you want, and if so, I hope the return request for them will be well received.

+5
source

Source: https://habr.com/ru/post/1236637/


All Articles