From d242659ac531a5163d073350e5897c51fca65fce Mon Sep 17 00:00:00 2001 From: Amethyst Reese Date: Tue, 30 May 2023 17:04:52 -0700 Subject: [PATCH] Simple pre-commit hook for usort Issue #260 ghstack-source-id: 1081271f25de255bedf5c2603647762f45dcf9cc Pull Request resolved: https://github.com/facebook/usort/pull/261 --- .pre-commit-hooks.yaml | 9 +++++++++ README.md | 15 ++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 .pre-commit-hooks.yaml diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 0000000..1395606 --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,9 @@ +- id: usort + name: Sort imports with µsort + description: Safe, minimal import sorting + language: python + types_or: + - python + - pyi + entry: usort format + require_serial: true diff --git a/README.md b/README.md index eb1fff0..d703f49 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,20 @@ To just validate that files are formatted correctly, like during CI: $ usort check ``` -# License +### pre-commit + +µsort provides a [pre-commit](https://pre-commit.com/) hook. To enforce sorted +imports before every commit, add the following to your `.pre-commit-config.yaml` +file: + +```yaml +- repo: https://github.com/facebook/usort + rev: v1.0.7 + hooks: + - id: usort +``` + +## License μsort is MIT licensed, as found in the [LICENSE][] file.