Why use the `src/` layout?
AdvancedConceptEnvironments, dependencies & packaging
Answer
With src/cloudaudit/ instead of cloudaudit/ at the repo root, the package is not importable just because you are in the repo directory. Tests therefore import the installed package, which catches packaging bugs (missing modules, missing package data, bad packages.find config) before you ship a broken wheel. It also prevents the accidental shadowing of installed packages by local folders.
More on Environments, dependencies & packaging
What is a virtual environment and why do we always use one?BeginnerWhat does `error: externally-managed-environment` mean?Beginner`requirements.txt` vs `pyproject.toml`: what goes where?IntermediateWhy is `pip freeze > requirements.txt` not a great lock strategy?IntermediateWhat do version specifiers like `~=`, `==`, `>=,<` mean?BeginnerWhat are `pipx` and `uv`, and when do you use them?Intermediate