From 948a47960160e76157621c4fdc9510887af7c82e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Valtonen=20=C3=96rnhag?= Date: Fri, 4 Apr 2025 18:36:35 +0200 Subject: [PATCH] Introduce automatic linting with Github workflows (#251) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add linters * use other setup-python version * Use string instead * Add more linting * Fix tests * minor changes --------- Co-authored-by: Marcus Valtonen Örnhag --- .github/workflows/tests-frontend.yml | 17 ++++++++++++++ .github/workflows/tests.yml | 17 ++++++++++++++ demo/gemini_conversation/app.py | 4 ++-- demo/talk_to_smolagents/app.py | 2 +- pyproject.toml | 33 ++++++++++++++++++++++++++++ 5 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/tests-frontend.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests-frontend.yml b/.github/workflows/tests-frontend.yml new file mode 100644 index 0000000..d72cb65 --- /dev/null +++ b/.github/workflows/tests-frontend.yml @@ -0,0 +1,17 @@ +name: tests + +on: [push, pull_request] + +jobs: + prettier: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Run prettier + run: | + cd frontend + npm install + npx prettier --check . \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..ce5759a --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,17 @@ +name: tests + +on: [push, pull_request] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Run linters + run: | + pip install ruff + ruff check . + ruff format --check --diff . \ No newline at end of file diff --git a/demo/gemini_conversation/app.py b/demo/gemini_conversation/app.py index 8dcb21c..9fb0959 100644 --- a/demo/gemini_conversation/app.py +++ b/demo/gemini_conversation/app.py @@ -190,13 +190,13 @@ if __name__ == "__main__": gr.HTML( """
-

Gemini Conversation

+

Gemini Conversation

""" ) gr.Markdown( """# How to run this demo - + - Clone the repo - top right of the page click the vertical three dots and select "Clone repository" - Open the repo in a terminal and install the dependencies - Get a gemini API key [here](https://ai.google.dev/gemini-api/docs/api-key) diff --git a/demo/talk_to_smolagents/app.py b/demo/talk_to_smolagents/app.py index 0638c7b..99231d7 100644 --- a/demo/talk_to_smolagents/app.py +++ b/demo/talk_to_smolagents/app.py @@ -26,7 +26,7 @@ conversation_state: List[Dict[str, str]] = [] # System prompt for agent system_prompt = """You are a helpful assistant that can helps with finding places to -workremotely from. You should specifically check against reviews and ratings of the +work remotely from. You should specifically check against reviews and ratings of the place. You should use this criteria to find the best place to work from: - Price - Reviews diff --git a/pyproject.toml b/pyproject.toml index a3a2a36..73ab183 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -83,5 +83,38 @@ artifacts = ["/backend/fastrtc/templates", "*.pyi"] packages = ["/backend/fastrtc"] [tool.ruff] +src = ["demo", "backend/fastrtc"] target-version = "py310" extend-exclude = ["demo/phonic_chat", "demo/nextjs_voice_chat"] + +[tool.ruff.format] +exclude = ["*.pyi"] +quote-style = "double" +indent-style = "space" +skip-magic-trailing-comma = false +line-ending = "auto" + +[tool.ruff.lint] +select = [ + "E", + "F", + "W", + "Q", + "I", +] + +# These can be turned on when the framework is more mature (Too many errors right now) +exclude = [ + "D", + "UP" +] + +# Avoid enforcing line-length violations (`E501`) +ignore = ["E501"] + +[tool.ruff.lint.pydocstyle] +convention = "google" + +[tool.ruff.lint.per-file-ignores] +"__init__.py" = ["E402"] +"demo/talk_to_smolagents/app.py" = ["W291"]