From 8aef179b2960b20c81179d9dab5a3995b0842281 Mon Sep 17 00:00:00 2001 From: Christoph Kieslich Date: Wed, 27 Nov 2024 07:19:43 +0100 Subject: [PATCH 1/3] feat: Add Ruff for linting and create configuration file --- .github/workflows/python.yml | 4 ++++ CONTRIBUTING.md | 2 ++ ruff.toml | 25 +++++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 ruff.toml diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index a1edc0c9ce..479aa1aa62 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -49,6 +49,10 @@ jobs: working-directory: src/${{ matrix.package }} run: uv run --frozen pyright + - name: Run Ruff + uses: astral-sh/ruff-action@v1 + src: src/${{ matrix.package }} + - name: Build package working-directory: src/${{ matrix.package }} run: uv build diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 88a0e03b12..9bdf99d3f5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -50,6 +50,8 @@ Documentation improvements are always welcome: - Follow the existing code style in the repository - Include appropriate type definitions - Add comments for complex logic +- Use `uvx ruff check` to check your code +- Use `uvx ruff format` to automatically format your code ### Documentation - Include a detailed README.md in your server directory diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 0000000000..2eb103c8c4 --- /dev/null +++ b/ruff.toml @@ -0,0 +1,25 @@ +# Support Python 3.10+. +target-version = "py310" +# Set the maximum line length to 79. +fix = true +line-length = 120 + +[lint] +select = [ + 'F', # Pyflakes + 'E', # pycodestyle (Error) + 'I', # isort + 'D', # pydocstyle + 'UP', # pyupgrade + 'YTT', # flake8-2020 + 'B', # flake8-bugbear + 'T10', # flake8-debugger + 'T20', # flake8-print + 'C4', # flake8-comprehensions + 'PYI006', # flake8-pyi + 'PYI062', # flake8-pyi + 'PYI063', # flake8-pyi + 'PYI066', # flake8-pyi +] +ignore = ['D100', 'D104', 'D101', 'D102', 'D103', 'D105', 'D107', 'D205','D400', 'D401', 'D415', 'E501', 'B011', 'B028', 'B904'] +flake8-quotes = {inline-quotes = 'single', multiline-quotes = 'double'} \ No newline at end of file From 8f5f82d8a2d907f36e7df033a93d70f931f0a867 Mon Sep 17 00:00:00 2001 From: Christoph Kieslich Date: Wed, 27 Nov 2024 13:48:02 +0100 Subject: [PATCH 2/3] docs: Update CONTRIBUTING.md to include Python server linting instructions --- CONTRIBUTING.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9bdf99d3f5..178d245ae0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -50,6 +50,9 @@ Documentation improvements are always welcome: - Follow the existing code style in the repository - Include appropriate type definitions - Add comments for complex logic + +#### For Python based servers + - Use `uvx ruff check` to check your code - Use `uvx ruff format` to automatically format your code From 653145079ec6e8d77cf2c469eef96ab1f47b77a4 Mon Sep 17 00:00:00 2001 From: Christoph Kieslich Date: Wed, 27 Nov 2024 13:48:11 +0100 Subject: [PATCH 3/3] style: Update line length in Ruff configuration to 79 characters --- ruff.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ruff.toml b/ruff.toml index 2eb103c8c4..8509b1044a 100644 --- a/ruff.toml +++ b/ruff.toml @@ -1,8 +1,6 @@ -# Support Python 3.10+. -target-version = "py310" # Set the maximum line length to 79. fix = true -line-length = 120 +line-length = 79 [lint] select = [