You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+4-37Lines changed: 4 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,44 +10,11 @@ Maintaining code quality can be challenging, no matter the size of your project
10
10
11
11
Pre-commit hooks are code checks that run whenever you attempt to commit your changes with `git`. They can detect and, in some cases, automatically correct code-quality issues *before* they make it to your code base. In this tutorial, you will learn how to install and configure pre-commit hooks for your repository to ensure that only code that passes your checks makes it into your code base. We will also explore how to build custom pre-commit hooks for novel use cases.
12
12
13
-
## Setup Instructions
14
-
15
-
1. Fork and clone this repository. If you don't have a GitHub account, you will need to create one to complete this step. Please be sure to check for changes (and sync them) before coming to the workshop.
16
-
17
-
2. Create a virtual environment using Python 3.10 or higher on your personal laptop, and install `pre-commit` in that virtual environment. You can use the tool of your choice (*e.g.*, `venv`, `conda`, `uv`), but do not attempt to install the project itself.
18
-
19
-
<details>
20
-
<summary>Using <code>venv</code></summary>
21
-
22
-
On Linux or MacOS:
23
-
24
-
```shell
25
-
python -m venv venv
26
-
source venv/bin/activate
27
-
python -m pip install -U pip # please make sure you have pip>=25.1
28
-
python -m pip install pre-commit
29
-
```
30
-
31
-
See https://docs.python.org/3/library/venv.html for more information and the Windows equivalent if you decide to use `venv`.
32
-
33
-
</details>
34
-
35
-
<details>
36
-
<summary>Using <code>uv</code></summary>
37
-
38
-
Note that this will install `pre-commit` as a tool for global use:
39
-
40
-
```shell
41
-
uv python install # install the Python version in .python-version, if not already installed
42
-
uv tool install pre-commit --with pre-commit-uv
43
-
```
44
-
45
-
</details>
46
-
47
-
3. Think about some potential ideas forthe pre-commit hook you would like to createin the second half of the workshop. Some ideas to get you started: prohibit `print()` calls, enforce file naming conventions, block large files, keep files under a certain number of lines, check for missing docstrings, disallow certain imports, *etc.*
[Stefanie Molin](https://stefaniemolin.com) ([@stefmolin](https://github.com/stefmolin)) is a software engineer at Bloomberg in New York City, where she tackles tough problems in information security, particularly those revolving around data wrangling/visualization, building tools for gathering data, and knowledge sharing. She is also a core developer of [numpydoc](https://github.com/numpy/numpydoc) and the author of [Hands-On Data Analysis with Pandas](https://www.amazon.com/dp/1800563450/), which is currently in its second edition and has been translated into Korean and Chinese. She holds a bachelor’s of science degree in operations research from Columbia University's Fu Foundation School of Engineering and Applied Science, as well as a master’s degree in computer science, with a specialization in machine learning, from Georgia Tech. In her free time, she enjoys traveling the world, inventing new recipes, and learning new languages spoken among both people and computers.
0 commit comments