A starter template for Python projects, pre-configured with type checking, linting, formatting, unittests, and more. This project provides a solid foundation for clean, maintainable Python code.
-
Create a virtual environment
To create an isolated environment for your project, run:python3 -m venv venv
-
Activate the virtual environment
Activate it with the following command:On macOS/Linux:
source venv/bin/activate
On Windows:
.\venv\Scripts\activate
-
Install dependencies
Install all the required dependencies listed inrequirements.txt
:pip3 install -r requirements.txt
Alternatively, you can use
make
to handle installation:make install
This project includes the following packages for development:
- mypy: A static type checker for Python, helping ensure that types are consistent and errors are caught early.
- flake8: A linting tool to check your code for style violations and potential errors based on PEP 8 and other best practices.
- black: An opinionated code formatter that enforces a consistent code style automatically.
- pytest: A framework for writing simple and scalable test cases. Ideal for running unit tests and ensuring code reliability.
You can use make
for common tasks such as installation and testing:
make install
make lint
make format
make test
mypy.ini
: Configuresmypy
for static type checking..flake8
: Configuration file forflake8
to enforce your preferred linting rules.pyproject.toml
: Configuration forblack
and other tools, ensuring consistent formatting across your project.Makefile
: Automates common tasks like installation, linting, formatting, and testing.
- Write your Python code in the
src
directory. - Use
make lint
to check for style violations. - Format your code with
make format
to ensure consistent formatting. - Write unit tests in the
tests
directory. - Run tests with
make test
to ensure everything works correctly.
- mypy documentation for type checking.
- flake8 documentation for linting setup and rules.
- black documentation for understanding code formatting rules.
- pytest documentation for testing guidelines and examples.
This setup ensures that your Python project stays clean, well-tested, and easy to maintain. Happy coding! 🚀