2

Example:

def exmaple_function():
            a = 1
            b = 2
            c = 3
            d = a * b + c
            print(d)

As you can see above function constitutes of 6 lines from start of (def) to end of (print(d)).

Is there a way to set limit in Pylint Config-file of the lines used inside python function? example: max-lines-of-function=4 using Pylint with configuration file.

90's_jaddu
  • 53
  • 8

1 Answers1

2

This is the too-many-statements warnings, the default value is 50 but you can change it to something else with a pylintrc configuration:

[DESIGN]
# Maximum number of statements in function / method body
max-statements=50
Pierre.Sassoulas
  • 3,733
  • 3
  • 33
  • 48
  • 1
    max-statements refers only to the number if else statments used inside a method/function, not exactly the number of line counts inside the function/method. – 90's_jaddu Jun 16 '21 at 07:59
  • And i am not refering to that warning, Instead is there a way to set warning saying that your function should not exceed to the limit sepcified for number of lines used inside the function. – 90's_jaddu Jun 16 '21 at 08:01
  • 1
    ``max-statements`` is exactly the option you're asking for, if you set the value to 5 it will raise a warning ``too-many-statements`` for the 6 lines function in your question. [Source](https://github.com/PyCQA/pylint/pull/4589/). – Pierre.Sassoulas Jun 17 '21 at 11:44