Our typechecker stumbled across this Protocol:
https://github.com/google/jax/blob/1c7f8efce64ca2927fd3f2de9250063d7c5fe09e/jax/_src/nn/initializers.py#L44
This is a Protocol with a @staticmethod. PEP 544 (
https://peps.python.org/pep-0544/) says only:
"Static methods, class methods, and properties are equally allowed in protocols."
The PEP doesn't say anything at all about what it *means* to have one of these in a structural supertype. Structurally, consider a Protocol like:
class P(Protocol):
def foo(x: str) -> int: ...
The protocol has an attribute named `foo` with type `(x: str) -> int`. @staticmethod is an implementation detail which does not affect the structure of P.
The protocol should be satisfied by *any* type with an attribute named `foo` with type `(x: str) -> int`.
(Similarly, if a protocol requires a @property getter you could satisfy it with a field, etc.)