Skip to content

Commit 360e2a9

Browse files
committed
Sync README with main
1 parent d8c7bff commit 360e2a9

1 file changed

Lines changed: 46 additions & 6 deletions

File tree

README.md

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,63 @@
11
# Pre-Commit Workshop
2-
32
[![View slides in browser](https://img.shields.io/badge/view-slides-orange?logo=reveal.js&logoColor=white)](https://stefaniemolin.com/pre-commit-workshop/) [![CC BY-NC-SA 4.0][cc-by-nc-sa-shield]][cc-by-nc-sa]
43

5-
This work is licensed under a
6-
[Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License][cc-by-nc-sa].
4+
The slides are licensed under a
5+
[Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License][cc-by-nc-sa]. Any code files in this repository are distributed under the Apache-2.0 license.
76

87
## Abstract
98

109
Maintaining code quality can be challenging, no matter the size of your project or number of contributors. Different team members may have different opinions on code styling and preferences for code structure, while solo contributors might find themselves spending a considerable amount of time making sure the code conforms to accepted conventions. However, manually inspecting and fixing issues in files is both tedious and error-prone. As such, computers are much more suited to this task than humans. Pre-commit hooks are a great way to have a computer handle this for you.
1110

12-
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.
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+
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 for the pre-commit hook you would like to create in 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.*
48+
1349
1450
## About the Author
1551
1652
[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.
1753
18-
## License
54+
## Licenses
55+
56+
### Code
57+
Any code files in this repository are distributed under the Apache-2.0 license.
1958
20-
This work is licensed under a
59+
### Slides
60+
The slides are licensed under a
2161
[Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License][cc-by-nc-sa].
2262
2363
[![CC BY-NC-SA 4.0][cc-by-nc-sa-image]][cc-by-nc-sa]

0 commit comments

Comments
 (0)