Warning when importing a local module with the same name as a 2nd or 3rd party module

Adding one more to the pile, yesterday I nearly went crazy debugging the project of a colleague where they had written a library foo and were testing a dev-install of it in a different project foo_test. At some point, they created a sub-package foo within foo_test and put a bunch of scripts in there that included from foo import bar without issues.

Insidiously, the next time they ran a script that was on the same level as the new foo subpackage, it crashed with Import- or Attribute-Errors due to shadowing. But because the creation of the subpackage was so far back in time and things continued to work just fine afterwards, they didn’t connect it to the issue at hand.