BSK-E0106
error
Protocol class used where typeProto is expected
The typing spec states: "Variables and parameters annotated with TypeProto accept only concrete (non-protocol) subtypes of Proto."
Passing the Protocol class itself (rather than a concrete subtype) violates this constraint.
class Proto(Protocol):
def meth(self) -> int: ...
class Concrete:
def meth(self) -> int: return 42
def fun(cls: type[Proto]) -> int:
return cls().meth()
fun(Proto) # E0106 — Protocol class passed to type[Proto]
fun(Concrete) # OK — concrete subtype
var: type[Proto]
var = Proto # E0106 — Protocol class assigned to type[Proto]
var = Concrete # OK
How to handle it
Every rule is on by default — strict is the default, not a cage. You can dial
BSK-E0106 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-E0106