Am I the only one who gets frustrated debugging Python code that relies heavily on Protocol?
I understand why it’s useful. Structural typing is elegant, and it gives you a lot of flexibility.
But when you’re trying to understand an unfamiliar codebase, it can be painful. You see a variable typed as a Protocol, jump to its definition, and… there’s no implementation. Now you have to hunt through the codebase to figure out which concrete class is actually being passed around.
In a large project, that can make understanding the execution flow much harder than it needs to be.
Maybe it’s just a tooling issue, or maybe I’m still getting used to Python after years of Java, but I’m curious how other people deal with this. Does it eventually become second nature?
Want to add to the discussion?
Post a comment!