Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python coding convention "Wrong continued indentation before block: found by pylint

I used pylint to check my python code, and found this convention problem:

C:11, 0: Wrong continued indentation before block.                     + this_time <= self.max):                     ^   | (bad-continuation) 

I tried to refine for times but the problem is still present, can someone help? Thanks!

if len(remaining_obj_list) > 0:     for i in a_list:         this_time = self.__get_time(i)         for remaining_obj in remaining_obj_list:             if (remaining_obj.get_time() # to fit 78 char rule                 + this_time <= self.max):                 i.append(remaining_obj)                 remaining_obj.set_used(True)         if 0 == len(self.__get_unused_list):             break 
like image 646
Reed_Xia Avatar asked Dec 14 '14 04:12

Reed_Xia


2 Answers

Pylint doesn't want such continuation to start on the same column as the next indentation block. Also, notice that the message includes a hint on columns that it considers correct.

like image 125
sthenault Avatar answered Sep 20 '22 12:09

sthenault


Try putting the + on the previous line:

        if (remaining_obj.get_time() +             this_time <= self.max): 

As a side note though, you might want to consider the factors that are causing your code to have to fit within ~40 characters - perhaps you have a few too many indentation levels and your code could be refactored to have fewer nested blocks.

like image 39
Amber Avatar answered Sep 20 '22 12:09

Amber