{"id":15628868,"url":"https://github.com/klieret/python-pre-commit-demo-tutorial","last_synced_at":"2025-08-22T09:31:59.056Z","repository":{"id":98217510,"uuid":"520948787","full_name":"klieret/python-pre-commit-demo-tutorial","owner":"klieret","description":"Try out useful pre-commits for python","archived":false,"fork":false,"pushed_at":"2024-12-03T00:42:41.000Z","size":42,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-03T01:29:51.618Z","etag":null,"topics":["pre-commit","teaching-materials","training-materials"],"latest_commit_sha":null,"homepage":"https://klieret.github.io/everything-you-didnt-now-you-needed/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/klieret.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-03T16:08:30.000Z","updated_at":"2024-10-10T15:50:41.000Z","dependencies_parsed_at":"2024-10-23T00:37:55.899Z","dependency_job_id":null,"html_url":"https://github.com/klieret/python-pre-commit-demo-tutorial","commit_stats":{"total_commits":36,"total_committers":2,"mean_commits":18.0,"dds":0.4722222222222222,"last_synced_commit":"0917c7357d763e0b6ba95a1b793ab86fccf453d6"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klieret%2Fpython-pre-commit-demo-tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klieret%2Fpython-pre-commit-demo-tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klieret%2Fpython-pre-commit-demo-tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klieret%2Fpython-pre-commit-demo-tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/klieret","download_url":"https://codeload.github.com/klieret/python-pre-commit-demo-tutorial/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230582708,"owners_count":18248660,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pre-commit","teaching-materials","training-materials"],"created_at":"2024-10-03T10:24:24.782Z","updated_at":"2024-12-20T11:40:35.395Z","avatar_url":"https://github.com/klieret.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Exercises: pre-commit for python projects\n\n[![PR welcome](https://img.shields.io/badge/PR-Welcome-%23FF8300.svg)](https://git-scm.com/book/en/v2/GitHub-Contributing-to-a-Project)\n\nThis repository demonstrates how you can catch a lot of python issues with\n[pre-commit](https://pre-commit.com/).\n\nPart of the lecture [Everything you didn't know you needed](https://github.com/klieret/everything-you-didnt-now-you-needed).\n\n## 📦 Exercise setup\n\nClone the demo repository\n\n```bash\ngit clone https://github.com/klieret/python-pre-commit-demo-tutorial.git\ncd python-pre-commit-demo-tutorial\n```\n\nIf you haven't done already, install the `pre-commit` package:\n\n```bash\npip3 install pipx\npipx install pre-commit\n```\n\nLet's take a look at the `pre-commit` configuration from the repository:\n\n```bash\ncat .pre-commit-config.yaml\n```\n\nLet's install these hooks:\n\n```bash\npre-commit install\n```\n\n## 🔥 Exercises\n\nNow let's open the `test.py` file in your favorite editor.\n\nTry one/each of the following modifications to `test.py`.\n\nAfter every modification, try to commit your change (`git commit -a`) and\nsee what happens.\nAlternatively, you can also simply run `pre-commit run -a` to run `pre-commit`\nover all files.\n\n1. Replace `return a + b` with `return None` (`mypy` will complain!)\n2. Remove spaces between `+` (`black` will automatically reformat the file and add the spaces back)\n3. Change `the` to `teh` in the docstring (`codespell` will flag it as a spelling mistake)\n4. Import `math` (`flake8` will complain about an unused iport)\n5. Add additional whitespace at the end of any line (`end-of-line-fixer` will fix it for you)\n\n\u003e **Note**:\n\u003e If you ever get stuck, run `git stash` (\"stashes\" away your changes) or\n\u003e `git reset --hard` (don't do that on an important repository without understanding\n\u003e the implications).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklieret%2Fpython-pre-commit-demo-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fklieret%2Fpython-pre-commit-demo-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklieret%2Fpython-pre-commit-demo-tutorial/lists"}