diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..3452165 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,10 @@ + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..5b64555 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,15 @@ + + +## Summary + + + +## Test Plan + + diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 861e15e..5b44ede 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,7 +4,7 @@ on: - cron: "0 */4 * * *" workflow_dispatch: repository_dispatch: - types: [pypi_release] + types: [ pypi_release ] jobs: build: @@ -27,6 +27,11 @@ jobs: git config user.name 'Github Actions' git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' - - run: pre-commit-mirror --language python --package-name ruff --entry 'ruff --force-exclude' --id ruff --types-or python --types-or pyi --require-serial --description "Run 'ruff' for extremely fast Python linting" . + - run: pre-commit-mirror --language python --package-name ruff --entry 'ruff check --force-exclude' --id ruff --types-or python --types-or pyi --require-serial --description "Run 'ruff' for extremely fast Python linting" . - run: git push origin HEAD:refs/heads/main --tags + + - name: "Update version in README.md" + run: python update_version.py + + - run: git push origin HEAD:refs/heads/main diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 9ce6d2a..8e18d85 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -1,7 +1,7 @@ - id: ruff name: ruff description: "Run 'ruff' for extremely fast Python linting" - entry: ruff --force-exclude + entry: ruff check --force-exclude language: python 'types_or': [python, pyi] args: [] diff --git a/.version b/.version index 48f075b..72a1b32 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -0.0.233 +0.0.284 diff --git a/README.md b/README.md index 6bd6c00..773bd7d 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,61 @@ # ruff-pre-commit -A [pre-commit](https://pre-commit.com/) hook for [Ruff](https://github.com/charliermarsh/ruff). +[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) +[![image](https://img.shields.io/pypi/v/ruff/0.0.283.svg)](https://pypi.python.org/pypi/ruff) +[![image](https://img.shields.io/pypi/l/ruff/0.0.283.svg)](https://pypi.python.org/pypi/ruff) +[![image](https://img.shields.io/pypi/pyversions/ruff/0.0.283.svg)](https://pypi.python.org/pypi/ruff) +[![Actions status](https://github.com/astral-sh/ruff-pre-commit/workflows/main/badge.svg)](https://github.com/astral-sh/ruff-pre-commit/actions) + +A [pre-commit](https://pre-commit.com/) hook for [Ruff](https://github.com/astral-sh/ruff). Distributed as a standalone repository to enable installing Ruff via prebuilt wheels from [PyPI](https://pypi.org/project/ruff/). -For pre-commit: see https://github.com/pre-commit/pre-commit +### Using Ruff with pre-commit -For Ruff: see https://github.com/charliermarsh/ruff +Add this to your `.pre-commit-config.yaml`: -### Using ruff with pre-commit +```yaml +- repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.0.283 + hooks: + - id: ruff +``` -Add this to your `.pre-commit-config.yaml`: +Or, to enable autofix: ```yaml -- repo: https://github.com/charliermarsh/ruff-pre-commit +- repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: 'v0.0.191' + rev: v0.0.283 hooks: - id: ruff + args: [--fix, --exit-non-zero-on-fix] ``` +To run the hook on Jupyter Notebooks too: + +```yaml +- repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.0.283 + hooks: + - id: ruff + types_or: [python, pyi, jupyter] +``` + +Ruff's pre-commit hook should be placed after other formatting tools, such as Black and isort, +_unless_ you enable autofix, in which case, Ruff's pre-commit hook should run _before_ Black, isort, +and other formatting tools, as Ruff's autofix behavior can output code changes that require +reformatting. + ## License MIT + +
+ + + +
diff --git a/setup.py b/setup.py index a2509b4..50dbf61 100644 --- a/setup.py +++ b/setup.py @@ -6,5 +6,5 @@ setup( name='pre_commit_placeholder_package', version='0.0.0', - install_requires=['ruff==0.0.233'], + install_requires=['ruff==0.0.284'], ) diff --git a/update_version.py b/update_version.py new file mode 100644 index 0000000..b98868f --- /dev/null +++ b/update_version.py @@ -0,0 +1,26 @@ +"""Updates the version in the readme and git commit.""" + +import re +from pathlib import Path +from subprocess import check_call, check_output + + +def main(): + readme_md = Path("README.md") + readme = readme_md.read_text() + rev = Path(".version").read_text().strip() + readme = re.sub(r"rev: v\d+\.\d+\.\d+", f"rev: v{rev}", readme) + readme = re.sub(r"/ruff/\d+\.\d+\.\d+\.svg", f"/ruff/{rev}.svg", readme) + readme_md.write_text(readme) + + # Only commit on change. + # https://stackoverflow.com/a/9393642/3549270 + if check_output(["git", "status", "-s"]).strip(): + check_call(["git", "add", readme_md]) + check_call(["git", "commit", "-m", f"Bump README.md version to {rev}"]) + else: + print("No change") + + +if __name__ == "__main__": + main()