I think the commenter meant that it can produce such an inconsistent result if the identifier names add up to approximately the line length, but the example didn't actually make it so; the identifiers are much shorter than that.
MkDocs has a good plugin system, and it's definitely possible to add a plugin to check each code block according to some rules. I know because I made one :)
Same. But for me there has been one particular recurring kind of breakage. Python version upgrades (most recently 3.8 -> 3.9) invalidate all manually installed packages and virtualenvs. Mitigated by using Arch packages for Python packages instead...