@@ -174,6 +174,9 @@ def from_content(cls, content: str | Sequence[str]) -> 'IndentationInfo':
174174
175175 return cls (char_count , dominant_char , min_indent_level , consistency , message )
176176
177+ def update_min_indent_level (self , content : str | Sequence [str ]) -> 'IndentationInfo' :
178+ return self ._replace (min_indent_level = IndentationInfo .from_content (content ).min_indent_level )
179+
177180 def level_difference (self , base_indentation_count : int ) -> int :
178181 """
179182 Calculate the difference in indentation levels.
@@ -211,7 +214,9 @@ def level_to_chars(self, level: int) -> str:
211214 return level * self .char_count * self .char
212215
213216 # TODO Revise
214- def shift_indentation (self , lines : Sequence [str ], target_base_indentation_count : int ) -> list [str ]:
217+ def shift_indentation (
218+ self , lines : Sequence [str ], target_base_indentation_count : int , relindent_level : int | None
219+ ) -> list [str ]:
215220 """
216221 Shift the indentation of a sequence of lines based on a target base indentation count.
217222
@@ -222,6 +227,7 @@ def shift_indentation(self, lines: Sequence[str], target_base_indentation_count:
222227 Args:
223228 lines (Sequence[str]): A sequence of strings representing the lines to be adjusted.
224229 target_base_indentation_count (int): The target base indentation count to adjust to.
230+ relindent_level (int|None):
225231
226232 Returns:
227233 list[str]: A new list of strings with adjusted indentation.
@@ -238,6 +244,7 @@ def shift_indentation(self, lines: Sequence[str], target_base_indentation_count:
238244 >>> info.shift_indentation(lines, 8)
239245 [' def example():', ' print('Hello')']
240246 """
247+ target_base_indentation_count += self .char_count * (relindent_level or 0 )
241248 raw_line_adjuster = self ._shift_indentation_fun (target_base_indentation_count )
242249 # Return the transformed lines
243250 return [raw_line_adjuster (line ) for line in lines ]
0 commit comments