Detecting incompatible signatures with Pylint

Another strong violation of LSP is when, instead of varying the types of the parameters on the hierarchy, the signatures of the methods differ completely. This might seem like quite a blunder, but detecting it would not always be so easy to remember; Python is interpreted, so there is no compiler to detect these type of error early on, and therefore they will not be caught until runtime. Luckily, we have static code analyzers such as Mypy and Pylint to catch errors such as this one early on.

While Mypy will also catch these type of error, it is not bad to also run Pylint to gain more insight.

In the presence of a class that breaks the compatibility defined by the hierarchy (for example, by changing ...

Get Clean Code in Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.