|
1 | | -# starter-repo |
2 | | -An example starter repo for Python projects |
| 1 | +# Python Project Starter Repository |
| 2 | + |
| 3 | +This repository serves as a template demonstrating Python best practices for data analysis projects. It includes: |
| 4 | + |
| 5 | +- An example Python program (reading in data and plotting) |
| 6 | +- Command-line argument parsing ([argparse](https://docs.python.org/3/library/argparse.html)) |
| 7 | +- Code style checking, aka "linting" (with [ruff](https://github.com/astral-sh/ruff)) |
| 8 | +- Static type checking (with [mypy](https://mypy.readthedocs.io/)) |
| 9 | +- Pre-commit hooks that run these checks automatically (with [pre-commit](https://pre-commit.com/)) |
| 10 | +- Testing (with [pytest](https://docs.pytest.org/)) |
| 11 | +- Continuous Integration (with [GitHub Actions](https://github.com/features/actions)) |
| 12 | +- Package management (with [pip](https://pip.pypa.io/) and [pyproject.toml](https://pip.pypa.io/en/stable/reference/build-system/pyproject-toml/)) |
| 13 | +- An open source license ([MIT](https://opensource.org/licenses/MIT)) |
| 14 | + |
| 15 | +## Features |
| 16 | + |
| 17 | +### 1. Data Processing and Visualization |
| 18 | + |
| 19 | +The main script ([starter_repo/plot_data.py](starter_repo/plot_data.py)) can be replaced with any code that you want to write. |
| 20 | + |
| 21 | +Installation can be done as follows: |
| 22 | + |
| 23 | +```bash |
| 24 | +# Install the package |
| 25 | +pip install . |
| 26 | + |
| 27 | +# Create a plot from the sample data |
| 28 | +python -m starter_repo.plot_data data/sample.csv year population --title "Population Growth" -o population.png |
| 29 | +``` |
| 30 | + |
| 31 | +### 2. Testing |
| 32 | + |
| 33 | +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/](tests/) directory. |
| 34 | + |
| 35 | +To run tests: |
| 36 | + |
| 37 | +```bash |
| 38 | +pip install ".[dev]" # Install development dependencies |
| 39 | +pytest |
| 40 | +``` |
| 41 | + |
| 42 | +### 3. Code Quality Tools |
| 43 | + |
| 44 | +This project uses several tools to maintain code quality: |
| 45 | + |
| 46 | +#### Pre-commit Hooks |
| 47 | + |
| 48 | +We use [pre-commit](.pre-commit-config.yaml) with: |
| 49 | + |
| 50 | +- [Ruff](https://github.com/charliermarsh/ruff) for linting and formatting |
| 51 | +- [mypy](https://mypy.readthedocs.io/) for static type checking |
| 52 | + |
| 53 | +To set up pre-commit: |
| 54 | + |
| 55 | +```bash |
| 56 | +pip install pre-commit |
| 57 | +pre-commit install |
| 58 | +``` |
| 59 | + |
| 60 | +### 4. Continuous Integration |
| 61 | + |
| 62 | +GitHub Actions workflows are set up for: |
| 63 | + |
| 64 | +- [Linting](.github/workflows/lint.yml): Runs Ruff and mypy |
| 65 | +- [Testing](.github/workflows/test.yml): Runs pytest on multiple Python versions |
| 66 | + |
| 67 | + |
| 68 | +## Contributing |
| 69 | + |
| 70 | +1. Fork the repository |
| 71 | +2. Install development dependencies: `pip install -e ".[dev]"` |
| 72 | +3. Install pre-commit hooks: `pre-commit install` |
| 73 | +4. Make your changes |
| 74 | +5. Run tests: `pytest` |
| 75 | +6. Submit a pull request |
| 76 | + |
| 77 | +## License |
| 78 | + |
| 79 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 80 | + |
| 81 | +> **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. |
| 82 | +
|
| 83 | +## Citation |
| 84 | + |
| 85 | +This was created by [Graham Neubig](https://phontron.com) primarily as an example for student researchers. |
| 86 | +If you use this repository in your research, please cite it using the following BibTeX entry: |
| 87 | + |
| 88 | +```bibtex |
| 89 | +@misc{neubig2025starter, |
| 90 | + author = {Graham Neubig}, |
| 91 | + title = {Python Project Starter Repository}, |
| 92 | + year = {2025}, |
| 93 | + publisher = {GitHub}, |
| 94 | + journal = {GitHub Repository}, |
| 95 | + howpublished = {\url{https://github.com/neubig/starter-repo}} |
| 96 | +} |
| 97 | +``` |
0 commit comments