Ctrl K
Python · Senior · Theory

When do you choose typing.Protocol and when an abstract base class? And how do you generally organize typing and mypy in a large project?

~4 min by voice

How to approach it

This checks whether you understand the difference between structural and nominal typing and can choose the tool deliberately, and whether you have real experience introducing mypy into a large codebase: doing it gradually, the costs, the limits of static checking.

Have you seen this question in a real interview?
Answers0
Avg. score—
Strong—
Practiced0
Topics
Similar questionsWhy does Python need type annotations if it's a dynamic language? Are they checked when the program runs? JuniorYour project just added mypy, and you need to type a function that accepts any object with a read method. Would you describe that type with a Protocol or with an abstract base class, and how do they differ? Mid-level

Answer by voice

The interviewer will ask this question and listen. Think out loud and ask for a hint if you need one. When you're done, pause or tap “That's my answer”. In about a minute, your score and the points you covered show up here.

Sign in to answer

Best with headphones · ~4 min