diff --git a/LICENSE b/LICENSE index feb81f7..a2559ba 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 Hassan Abedi +Copyright (c) 2025 Hassan Abedi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4005bc6 --- /dev/null +++ b/Makefile @@ -0,0 +1,64 @@ +# Variables +PYTHON = python +PIP = pip +POETRY = poetry + +# Default target +.DEFAULT_GOAL := help + +.PHONY: help +help: ## Show this help message + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +.PHONY: install +install: ## Install dependencies + $(POETRY) install + +.PHONY: test +test: ## Run tests + $(POETRY) run pytest + +.PHONY: lint +lint: ## Run ruff and flake8 + $(POETRY) run ruff check . + $(POETRY) run flake8 . + +.PHONY: format +format: ## Format code with ruff and black + $(POETRY) run ruff format . + $(POETRY) run black . + +.PHONY: mypy +mypy: ## Run mypy + $(POETRY) run mypy . + +.PHONY: clean +clean: ## Clean up generated files + find . -type f -name '*.pyc' -delete + find . -type d -name '__pycache__' -exec rm -r {} + + rm -rf .mypy_cache + rm -rf .pytest_cache + rm -rf .ruff_cache + rm -rf .coverage + rm -rf htmlcov + rm -rf coverage.xml + rm -rf junit + +.PHONY: coverage +coverage: ## Run tests with coverage + $(POETRY) run pytest --cov=src --cov-report=term-missing + +.PHONY: build +build: ## Build the project + $(POETRY) build + +.PHONY: check +check: lint mypy test ## Run lint, mypy, and tests + +.PHONY: all +all: install check build ## Install dependencies, run checks, and build the project + +.PHONY: precommit +precommit: ## Install and run pre-commit hooks + $(POETRY) run pre-commit install + $(POETRY) run pre-commit run --all-files diff --git a/README.md b/README.md index e92c978..fb3abb4 100644 --- a/README.md +++ b/README.md @@ -4,27 +4,24 @@ [![Python Version](https://img.shields.io/badge/Python-%3E=3.10-blue)](https://github.com/habedi/template-python-project) [![License](https://img.shields.io/badge/License-MIT-blue)](https://github.com/habedi/template-python-project/blob/main/LICENSE) -This is a simple and minimalistic template repository for starting new data science and machine learning projects in -Python. +This is a template repository for starting new data science and machine learning projects in Python. -I created this template to help me speed up the setup process for my projects. -And to have a consistent structure across all my personal and professional projects. -I'm sharing it here in the hope that others find it useful. -So, feel free to use it as a starting point for your projects. +I created this template to help me speed up the setup process for my projects and to have a consistent structure across +all my personal and professional projects. +I'm sharing it here in case it might be useful to others as well. --- -## Notable Features +## Features - A predefined file and folder layout that should be suitable for most data science workflows. -- Easy dependency and environment management with [Poetry](https://python-poetry.org/). +- Easy dependency and environment management with [Poetry](https://python-poetry.org/) + or [uv](https://github.com/astral-sh/uv). - Extra configuration files for various tasks like linting, formatting, and testing. --- -## Folder Structure - -The repository is organized as follows: +## Structure ```plaintext template-python-project/ @@ -36,7 +33,8 @@ template-python-project/ ├── tests/ # Unit tests and test files ├── pyproject.toml # Project metadata and dependencies ├── LICENSE # License information -└── README.md # Project documentation +├── README.md # Project documentation +└── Makefile # Makefile for managing common tasks like linting and testing ``` --- diff --git a/pyproject.toml b/pyproject.toml index 7eb6df0..a56db32 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,6 +19,8 @@ pytest-cov = "^6.0.0" pytest-mock = "^3.14.0" mypy = "^1.11.1" ruff = "^0.8.6" +black = "^24.10.0" +flake8 = "^7.1.1" [tool.poetry.scripts] cli_script = "src.cli:main" @@ -28,7 +30,7 @@ requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" [tool.pytest.ini_options] -pythonpath = [".", "src", 'bin'] +pythonpath = [".", "src", 'bin', 'notebooks'] [tool.mypy] python_version = "3.10" @@ -69,14 +71,14 @@ exclude = [ ] line-length = 100 indent-width = 4 -src = ["mongo_analyser", "tests"] -target-version = "py311" +src = ["src", "tests", "bin", "notebooks"] +target-version = "py310" [tool.ruff.lint] select = ["ANN", "D", "E", "F", "I"] ignore = [ - "ANN101", # Don't annotate self - "ANN102" # Don't annotate cls + # Ignore missing docstrings + "D100", "D101", "D102", "D103", "D104", "D105", "D106", "D107", ] fixable = ["ALL"] unfixable = []