BSK-E0097 error

Protocol method sets self-attributes not declared in the Protocol

When a Protocol class defines a method (including __init__/__new__) that assigns to self.attr where attr is not a declared member of the Protocol, this is a violation: per the typing spec, "additional attributes only defined in the body of a method by assignment via self are not allowed". Protocol members must be explicitly declared at the class level.

from typing import Protocol

class MyProto(Protocol):
    x: int
    def __init__(self) -> None:
        self.y = 0  # E — `y` is not declared in the Protocol
    def method(self) -> None:
        self.z: int = 0  # E — `z` is not declared in the Protocol

@staticmethod/@classmethod members have no instance receiver, so their first parameter is not self and is not analysed here.

How to handle it

Every rule is on by default — strict is the default, not a cage. You can dial BSK-E0097 down per-file or per-path from your editor or pyproject.toml, or fix the code so it type-checks. See the Type System rules and the complete diagnostic reference.

Canonical URL: https://www.basilisk-python.dev/errors/BSK-E0097