From 8ca47e5dc448a98f4603bd2528279199e4f49180 Mon Sep 17 00:00:00 2001 From: Joachim Jablon Date: Tue, 30 Nov 2021 14:30:18 +0100 Subject: [PATCH 1/3] Remove deprecated pre-commit script and adjust doc --- CONTRIBUTING.md | 17 ++++++++++++++--- pre-commit | 28 ---------------------------- 2 files changed, 14 insertions(+), 31 deletions(-) delete mode 100755 pre-commit diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cd13e6962a63..732fc00c83dc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,9 +29,7 @@ run the tests, it can be useful to prepare a [virtual environment](https://docs.python.org/3/tutorial/venv.html) and install certain libraries typeshed uses to check stub files. -Follow platform-specific instructions below. Following that, to automatically -check your code before committing, you can copy the file `pre-commit` to -`.git/hooks/pre-commit`. +Follow platform-specific instructions below. ### Linux/Mac OS @@ -74,6 +72,19 @@ following commands from a Windows terminal: (.venv3) > python -m pip install -r requirements-tests-py3.txt ``` +## Code formatting + +The code is formatted by `black` and `isort`. + +The repository is equipped with a [`pre-commit.ci`](https://pre-commit.ci/) +configuration file. This means that you don't *need* to do anything yourself to +run the code formatters. When you push a commit, a bot will run those for you +right away and add a commit to your PR. Neat, no ? + +That being said, if you *want* to run the checks locally when you commit, you +can install the hooks: please refer to the [pre-commit](https://pre-commit.com/) +documentation. + ## Where to make changes ### Standard library stubs diff --git a/pre-commit b/pre-commit deleted file mode 100755 index b3d79c25c209..000000000000 --- a/pre-commit +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# -# An example hook script that will run flake8, black, and isort -# prior to committing and will stop the commit if there are any -# warnings. Adjust BIN_DIR to the virtual environment where flake8, -# black, and isort are installed. -# -# To enable this hook, copy this file to ".git/hooks". - -BIN_DIR=./.venv3/bin - -CHANGED_FILES=$(git diff --cached --name-only --diff-filter=AM | grep .pyi || true) - -if test -n "${CHANGED_FILES}" -a -d "${BIN_DIR}"; then - ${BIN_DIR}/flake8 ${CHANGED_FILES} - ${BIN_DIR}/black --check ${CHANGED_FILES} - ${BIN_DIR}/isort --check-only ${CHANGED_FILES} - - # Replace the last two lines with the following lines - # if you want to reformat changed files automatically - # before committing. Please note that partial commits - # (git add -p) will not work and will commit the whole - # file! - # - # ${BIN_DIR}/black ${CHANGED_FILES} || true - # ${BIN_DIR}/isort -y ${CHANGED_FILES} || true - # git add ${CHANGED_FILES} -fi From fcbfeabafd6395a5aef4634345825149f1c1f400 Mon Sep 17 00:00:00 2001 From: Joachim Jablon Date: Tue, 30 Nov 2021 17:59:26 +0100 Subject: [PATCH 2/3] Clarify contributing doc --- CONTRIBUTING.md | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 732fc00c83dc..6c20fff4fdda 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,12 +24,23 @@ it takes a bit longer. For more details, read below. ## Preparing the environment -To reformat the code, check for common problems, and -run the tests, it can be useful to prepare a -[virtual environment](https://docs.python.org/3/tutorial/venv.html) and install -certain libraries typeshed uses to check stub files. +### Code away! -Follow platform-specific instructions below. +This repository has a Continuous Integration (CI) running on the pull requests, +which includes automatically adjusting code formatting (`black`, `isort`) and +running the tests. It means you can ignore all this on your side, focus on the +code and rely on the CI to fix everything, or point you to the places that need +fixing. + +### ... Or create a local development environment + +If you prefer to run the tests & formatting locally, it's +possible too. Follow platform-specific instructions below. + +Whichever platform you're using, you will need a +virtual environment. If you're not familiar with what it is and how it works, +please refer to this +[documentation](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/). ### Linux/Mac OS @@ -79,7 +90,7 @@ The code is formatted by `black` and `isort`. The repository is equipped with a [`pre-commit.ci`](https://pre-commit.ci/) configuration file. This means that you don't *need* to do anything yourself to run the code formatters. When you push a commit, a bot will run those for you -right away and add a commit to your PR. Neat, no ? +right away and add a commit to your PR. Neat, no? That being said, if you *want* to run the checks locally when you commit, you can install the hooks: please refer to the [pre-commit](https://pre-commit.com/) From 7157670d8a6a4e8200400dc617d1e8dca469c675 Mon Sep 17 00:00:00 2001 From: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Date: Tue, 30 Nov 2021 11:04:35 -0800 Subject: [PATCH 3/3] Update CONTRIBUTING.md --- CONTRIBUTING.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6c20fff4fdda..e81dc42e17c9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,11 +26,11 @@ it takes a bit longer. For more details, read below. ### Code away! -This repository has a Continuous Integration (CI) running on the pull requests, -which includes automatically adjusting code formatting (`black`, `isort`) and -running the tests. It means you can ignore all this on your side, focus on the -code and rely on the CI to fix everything, or point you to the places that need -fixing. +Typeshed runs continuous integration (CI) on all pull requests. This will +automatically fix formatting (using `black`, `isort`) and run tests. +It means you can ignore all local setup on your side, focus on the +code and rely on the CI to fix everything, or point you to the places that +need fixing. ### ... Or create a local development environment