This is a Python project named "mduck". It is managed using Poetry for dependency management and packaging. The project's source code is located in the src/mduck directory.
This project uses python-dependency-injector for dependency injection to manage components and their dependencies.
The project follows the following structure:
src/mduck/containers/*.py: Dependency-injector containers.src/mduck/repositories/*.py: Data-access layer.src/mduck/routers/*.py: API layer with FastAPI routers.src/mduck/schemas/*.py: Pydantic schemas for data validation and serialization.src/mduck/services/*.py: Business logic.src/config/settings.py: Configuration using Pydantic-settings.
To install the necessary dependencies, run the following command in the project root:
poetry installTo run the application, use the following command:
poetry run api --host 0.0.0.0 --port 8000 --reload --log-level infoTo run tests and check coverage, use:
poetry run pytest --cov=src/mduck-
All Python source code should be placed within the
src/mduckdirectory. -
Tests should be placed in the
tests/directory. The structure of thetestsdirectory should mirror thesrc/mduckdirectory. -
Dependencies Dependencies are managed via the
pyproject.tomlfile. To add a new dependency, use:poetry add <package-name>
For development-only dependencies, use:
poetry add --group dev <package-name>
-
Import Paths When importing modules, treat the
srcdirectory as the project root. For example, to importsettingsfromsrc/config/settings.py, usefrom config.settings import settings. Similarly, for modules withinsrc/mduck, usefrom mduck.<module> import .... Do not prefix imports withsrc.. -
Commit Messages This project follows the Conventional Commits specification. All commit messages should adhere to this format.
-
Type Annotations All code must use type annotations wherever possible, including function arguments, return values, and class attributes. This is enforced by
mypy. -
Linting and Formatting To lint and format the code using
ruff:poetry run ruff check src/mduck tests poetry run ruff format src/mduck tests
-
Type Checking To perform static type checking using
mypy:poetry run mypy --strict src/mduck