A Pydantic model declares an attribute whose name starts with two underscores, which Python renames
What it finds
Inside a class body, __secret is renamed to _Model__secret by name mangling, so Pydantic neither treats it as a private attribute under the written name nor as a field, and access from outside the class fails. A single underscore declares a private attribute.
From the rule's source, pydantic_mangled_attribute.rs.
from pydantic import BaseModel class M(BaseModel): __token: str = ""tx0 reports: two leading underscores make Python rename this attribute _cache: dict = {} __slots__ = () Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/python:pydantic-mangled-attribute" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
# tx0: ignore[tx0/python:pydantic-mangled-attribute] reason="..."tx0 explain tx0/python:pydantic-mangled-attribute shows the same in the terminal. Found a false positive? Report it.