by 4kelly · 4y ago · 0 comments
(Similar to when you something you wrote is hard to test, it’s probably just poorly abstracted code.)
One example is that variable re-assignment can cause type errors in mypy but re-assigning a variable to a value of a different type is an extremely common and reasonable thing to do in Python. Another situation where strict typing can be borderline hopeless is when parsing e.g. very dynamic content like json. Sure you could encode every possible situation using types but this would basically defeat the purpose of using Python for such a task.