Łukasz Rogalski
Łukasz Rogalski

Reputation: 23213

Pylint: overriding max-line-length in individual file

Is it possible to change max-line-length settings for one file out of a project (while performing all other checks defined in rc file on it)?

Ideally, it should behave like inline pylint: disable=x comments.

I've tried putting this line at the module level:

# pylint: max-line-length=240

PyLint failed to recognize it:

my_file.py:15: [E0011(unrecognized-inline-option), ] Unrecognized file option 'max-line-length

Edit: I know I can disable line-too-long check entirely, but to be honest I'd like to avoid doing so, just in case anyone would try to extend this module and add lines even longer than they are now.

Upvotes: 67

Views: 105793

Answers (4)

Omrum Cetin
Omrum Cetin

Reputation: 1469

You can create .pylintrc file in your python script to overwrite pylint settings and put inside

[FORMAT]
max-line-length=240

edit 240 based on your choice.

Upvotes: 87

Tryph
Tryph

Reputation: 6209

According to the doc, I think you cannot modify the pylint config in line. but you can disable the warning for only one or few line(s) with # pylint: disable=line-too-long:

# disable for only one line
ridiculously_long_variable_name = "this is not a ridiculously long and useless python line"  # pylint: disable=line-too-long

# disable for few (or more) lines 
# pylint: disable=line-too-long
ridiculously_long_variable_name = "this is not a ridiculously long and useless python line"
# pylint: enable=line-too-long

Upvotes: 25

Kamal Hasan
Kamal Hasan

Reputation: 331

pylint --max-line-length=240

works for me.

Upvotes: 20

Nandeesh
Nandeesh

Reputation: 2802

You can pass the additional as below: C:\Python27\Scripts\pylint.exe --max-line-length=240 <PATH TO FILE>

Upvotes: 10

Related Questions