In short
A package should be used through its front door (its __init__/__all__), not by reaching into its internal files. This fails when someone writes from mypkg.internal.thing import X instead of from mypkg import X, so you can refactor internals freely.
Problem
Packages should expose a deliberate public surface; deep imports into a package's internals silently break encapsulation and make refactoring risky.
Proposal
A rule that a package may be imported only via its declared public interface (its __init__ / __all__), not its submodules' internals, e.g. project_files("src/").in_folder("**/mypkg/**").should().only_be_imported_via_public_interface(); deep cross-package imports fail.
Acceptance criteria
In short
A package should be used through its front door (its
__init__/__all__), not by reaching into its internal files. This fails when someone writesfrom mypkg.internal.thing import Xinstead offrom mypkg import X, so you can refactor internals freely.Problem
Packages should expose a deliberate public surface; deep imports into a package's internals silently break encapsulation and make refactoring risky.
Proposal
A rule that a package may be imported only via its declared public interface (its
__init__/__all__), not its submodules' internals, e.g.project_files("src/").in_folder("**/mypkg/**").should().only_be_imported_via_public_interface(); deep cross-package imports fail.Acceptance criteria
from mypkg.internal.thing import Xfrom outsidemypkgfails;from mypkg import X(the public interface) passes.__all__/__init__and is configurable.