3

I have the following code section that triggers Pylint error "E1120: No value for argument if".

framework/packages/create_network.py:79:21: E1120: No value for argument 'bridge1' in function call (no-value-for-parameter)

Is there a flag for Pylint that can bypass this check for this specific case? I am looking for a solution that doesn't require changes in the code itself and is a parameter passed to Pylint.

In my answer I will put the flag I am familiar with that is an annotation in the code.

Description of the case

This happens when passing an unpacked list as values to parameters defined by name and not by *args.

The script passes a list

bridges = create_bridge(interface1, interface2)   # Returns an array of 4 values
routers = get_routers(*bridges)   # Unpacks the array and passes values to 4 parameters 

And the function signature is

def get_routers(bridge1, bridge2, bridge3, bridge4):
RaamEE
  • 3,017
  • 4
  • 33
  • 53

1 Answers1

2

This can be solved by disabling the specific check for E1120 for the specific line that causes the issue.

In this case the code will now have a pylint disable comment above the

bridges = create_bridge(interface1, interface2)   # Returns an array of 4 values
#pylint: disable = no-value-for-parameter   # Disables the pylint check for the next line
routers = get_routers(*bridges)   # Unpacks the array and passes values to 4 parameters 

I dislike this solution because it forces me to change the itself. I'd prefer to disable this check when running Pylint as an optional flag just for unpacking list to parameters.

RaamEE
  • 3,017
  • 4
  • 33
  • 53