Python S930 False Positive using pydantic.conlist(min_length=1)

  • Product: SonarQube Cloud
  • Language: Python
  • Rule: S930 → “Remove this unexpected named argument ‘min_length’”
  • Justification: Using pydantic v2.10.6 python library, the argument min_length is a valid property of pydantic.conlist’s function signature.

Code to reproduce:

from pydantic.main import BaseModel
from pydantic.types import conlist

class ExampleClass(BaseModel):
    my_types: conlist(item_type=int, min_length=1) | None = None 

Outcome:

Hello @vincentmorel,

Thank you for reporting this false positive, and my apologies for the late answer.
I confirm this is a false positive, due to an outdated stub version of Pydantic embedded in the analyzer.

I created the following ticket to fix this.

Cheers,
Guillaume

1 Like