Skip to content

loop_threshold

Type: int Default: 10


Description

Controls when rules L001, L002, and L003 fire for for loops.

  • for loops — only flagged when range(N) exceeds loop_threshold. A loop over range(3) with threshold 10 is not flagged.
  • while loops — always assumed to run 99 iterations and are always flagged regardless of this threshold.

Example

[tool.pyspark-antipattern]
# Only flag for-loops that could run more than 50 iterations
loop_threshold = 50

Notes

Info

while loops are always flagged because their iteration count cannot be statically determined — the worst case is assumed.

  • Set loop_threshold = 0 to flag all for loops regardless of range
  • Related rules: L001, L002, L003