This repository serves as a template demonstrating Python best practices for research projects. It includes:
- An example Python program (reading in data and plotting)
- Command-line argument parsing (argparse)
- Code style checking, aka "linting" (with ruff)
- Static type checking (with mypy)
- Pre-commit hooks that run these checks automatically (with pre-commit)
- Testing (with pytest)
- Continuous Integration (with GitHub Actions)
- Package management (with pip and pyproject.toml)
- An open source license (MIT)
The main script (starter_repo/plot_data.py) can be replaced with any code that you want to write.
Installation can be done as follows:
# Install the package
pip install .
# Create a plot from the sample data
python -m starter_repo.plot_data data/sample.csv year population --title "Population Growth" -o population.png
Writing unit tests is a good way to ensure that your code behaves as expected, and you can write unit tests before you write the code that you want to test (aka "test-driven development"). Test files are located in the tests/ directory.
To run tests:
pip install ".[dev]" # Install development dependencies
pytest
This project uses several tools to maintain code quality:
We use pre-commit with:
To set up pre-commit:
pip install pre-commit
pre-commit install
GitHub Actions workflows are set up for:
- Fork the repository
- Install development dependencies:
pip install -e ".[dev]"
- Install pre-commit hooks:
pre-commit install
- Make your changes
- Run tests:
pytest
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Note: Without a license, the code is under exclusive copyright by default. This means no one can copy, distribute, or modify your work without facing potential legal consequences. Adding a license (like MIT) explicitly grants these permissions, making it clear how others can use your code.
This was created by Graham Neubig primarily as an example for student researchers. If you use this repository in your research, please cite it using the following BibTeX entry:
@misc{neubig2025starter,
author = {Graham Neubig},
title = {Python Project Starter Repository},
year = {2025},
publisher = {GitHub},
journal = {GitHub Repository},
howpublished = {\url{https://github.com/neubig/starter-repo}}
}