From 55637f31d91aef59419e1fcbea562fd545f99d35 Mon Sep 17 00:00:00 2001 From: drisspg Date: Thu, 15 Aug 2024 10:55:48 -0700 Subject: [PATCH] add in formatting skip everything ghstack-source-id: 34fe56595eac4d1a2fecb07a230307c0b2b767d7 Pull Request resolved: https://github.com/pytorch/ao/pull/688 --- .github/workflows/ruff_linter.yml | 30 ++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 20 ++++++++++++++++++++ dev-requirements.txt | 4 ++++ ruff.toml | 1 + 4 files changed, 55 insertions(+) create mode 100644 .github/workflows/ruff_linter.yml create mode 100644 .pre-commit-config.yaml create mode 100644 ruff.toml diff --git a/.github/workflows/ruff_linter.yml b/.github/workflows/ruff_linter.yml new file mode 100644 index 000000000..c6a406ca6 --- /dev/null +++ b/.github/workflows/ruff_linter.yml @@ -0,0 +1,30 @@ +name: Code Analysis with Ruff + +on: + push: + branches: + - main + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10"] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install ruff + - name: Analyzing the code with ruff + run: | + ruff check . + - name: Check well formatted code + run: | + ruff format --check diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..cdc0181ed --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,20 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + + - repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.5.6 + hooks: + # Run the linter. + # - id: ruff + # args: [--fix] + # Run the formatter. + - id: ruff-format diff --git a/dev-requirements.txt b/dev-requirements.txt index a400b1c1e..6fdcb0aca 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -17,3 +17,7 @@ tabulate # QOL for printing tables to stdout # Custom CUDA Extensions ninja + +# Linting +ruff +pre-commit diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 000000000..34ffae403 --- /dev/null +++ b/ruff.toml @@ -0,0 +1 @@ +exclude = ["**/*"]