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 28cba5a6e8..9cc368746d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -57,6 +57,11 @@ Documentation improvements are always welcome: - 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 + ### Documentation - Include a detailed README.md in your server directory - Document all configuration options diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 0000000000..8509b1044a --- /dev/null +++ b/ruff.toml @@ -0,0 +1,23 @@ +# Set the maximum line length to 79. +fix = true +line-length = 79 + +[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