From 44f296d28fc4f4c4a02cfc6d7f29ff57a4103391 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Fri, 13 Sep 2024 15:28:11 +0200 Subject: [PATCH] style: :art: update pre-commit by using ruff --- .github/workflows/main-ci.yml | 7 +++++ .gitignore | 3 +- .pre-commit-config.yaml | 22 ++++++------- backend/src/router.py | 1 - backend/src/utils.py | 1 + backend/tests/test_auth.py | 1 - frontend/src/components.d.ts | 58 +++++++++++++++++------------------ 7 files changed, 50 insertions(+), 43 deletions(-) diff --git a/.github/workflows/main-ci.yml b/.github/workflows/main-ci.yml index db989f237..976eb504b 100644 --- a/.github/workflows/main-ci.yml +++ b/.github/workflows/main-ci.yml @@ -8,6 +8,13 @@ on: - develop jobs: + pre-commit-check: + name: Check pre-commit hooks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: pip install pre-commit && pre-commit run --all-files + build-backend: name: Build Backend runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 79b631171..244c7dc4e 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,5 @@ temp/ *.secrets* version.txt *.crt -*.pem \ No newline at end of file +*.pem +.ruff_cache \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index acbcb4919..b7f7295ac 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,15 +1,15 @@ -# See https://pre-commit.com for more information -# See https://pre-commit.com/hooks.html for more hooks repos: -- repo: https://github.com/psf/black - rev: 22.10.0 - hooks: - - id: black -- repo: https://github.com/PyCQA/isort - rev: 5.12.0 - hooks: - - id: isort - args: ["--profile", "black"] +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.6.4 + hooks: + # Run ruff with isort formatter + - id: ruff + args: [ "--select", "I", "--fix" ] + # Run ruff + - id: ruff + args: [ "--fix" ] + # Run the formatter. + - id: ruff-format - repo: local hooks: - id: prettier diff --git a/backend/src/router.py b/backend/src/router.py index 5ab682366..b87843ac7 100644 --- a/backend/src/router.py +++ b/backend/src/router.py @@ -22,7 +22,6 @@ from user_agents import parse from .config import APP_VERSION, S3_PREFIX, TYPOLOGIES_MEASURED, get_base_logs -from .models import EmailData from .utils import get_current_user, send_mail, upload_image router = APIRouter(prefix="/api") diff --git a/backend/src/utils.py b/backend/src/utils.py index 39809aa48..ff315bf68 100644 --- a/backend/src/utils.py +++ b/backend/src/utils.py @@ -6,6 +6,7 @@ import jwt from fastapi import Depends, HTTPException, status + from src.config import SMTPClient from .config import OAUTH2_SCHEME, PUBLIC_KEY, S3, S3_BUCKET_NAME diff --git a/backend/tests/test_auth.py b/backend/tests/test_auth.py index 829006e73..eaebbabeb 100644 --- a/backend/tests/test_auth.py +++ b/backend/tests/test_auth.py @@ -1,5 +1,4 @@ import jwt -import pytest from fastapi.testclient import TestClient from src.config import PUBLIC_KEY from src.main import app diff --git a/frontend/src/components.d.ts b/frontend/src/components.d.ts index ba76770c4..dbbe9e110 100644 --- a/frontend/src/components.d.ts +++ b/frontend/src/components.d.ts @@ -5,35 +5,35 @@ // Read more: https://github.com/vuejs/core/pull/3399 export {} -declare module 'vue' { +declare module "vue" { export interface GlobalComponents { - AskingExpert: typeof import('./components/AskingExpert.vue')['default'] - AuthCallback: (typeof import("./components/authentication/AuthCallback.vue"))["default"] - AuthRedirect: (typeof import("./components/authentication/AuthRedirect.vue"))["default"] - ContactExpert: typeof import('./components/ContactExpert.vue')['default'] - copy: (typeof import("./components/authentification/AuthRedirect copy.vue"))["default"] - DsfrAlert: typeof import('@gouvminint/vue-dsfr')['DsfrAlert'] - DsfrButton: typeof import('@gouvminint/vue-dsfr')['DsfrButton'] - DsfrCheckbox: typeof import('@gouvminint/vue-dsfr')['DsfrCheckbox'] - DsfrFileUpload: typeof import('@gouvminint/vue-dsfr')['DsfrFileUpload'] - DsfrHeader: typeof import('@gouvminint/vue-dsfr')['DsfrHeader'] - DsfrInput: typeof import('@gouvminint/vue-dsfr')['DsfrInput'] - DsfrModal: typeof import('@gouvminint/vue-dsfr')['DsfrModal'] - DsfrPicture: (typeof import("@gouvminint/vue-dsfr"))["DsfrPicture"] - DsfrRadioButton: (typeof import("@gouvminint/vue-dsfr"))["DsfrRadioButton"] - DsfrSelect: typeof import('@gouvminint/vue-dsfr')['DsfrSelect'] - DsfrTag: (typeof import("@gouvminint/vue-dsfr"))["DsfrTag"] - HeaderMain: typeof import('./components/HeaderMain.vue')['default'] - MissingCardAlert: typeof import('./components/MissingCardAlert.vue')['default'] - OnboardingSwiper: typeof import('./components/OnboardingSwiper.vue')['default'] - PopupContact: typeof import('./components/PopupContact.vue')['default'] - PopupVideo: typeof import('./components/PopupVideo.vue')['default'] - ResultPage: typeof import('./components/ResultPage.vue')['default'] - RouterLink: typeof import('vue-router')['RouterLink'] - RouterView: typeof import('vue-router')['RouterView'] - SnackbarAlert: typeof import('./components/SnackbarAlert.vue')['default'] - StepsGuide: typeof import('./components/StepsGuide.vue')['default'] - User: (typeof import("./components/authentication/User.vue"))["default"] - VIcon: typeof import('oh-vue-icons')['OhVueIcon'] + AskingExpert: (typeof import("./components/AskingExpert.vue"))["default"]; + AuthCallback: (typeof import("./components/authentication/AuthCallback.vue"))["default"]; + AuthRedirect: (typeof import("./components/authentication/AuthRedirect.vue"))["default"]; + ContactExpert: (typeof import("./components/ContactExpert.vue"))["default"]; + copy: (typeof import("./components/authentification/AuthRedirect copy.vue"))["default"]; + DsfrAlert: (typeof import("@gouvminint/vue-dsfr"))["DsfrAlert"]; + DsfrButton: (typeof import("@gouvminint/vue-dsfr"))["DsfrButton"]; + DsfrCheckbox: (typeof import("@gouvminint/vue-dsfr"))["DsfrCheckbox"]; + DsfrFileUpload: (typeof import("@gouvminint/vue-dsfr"))["DsfrFileUpload"]; + DsfrHeader: (typeof import("@gouvminint/vue-dsfr"))["DsfrHeader"]; + DsfrInput: (typeof import("@gouvminint/vue-dsfr"))["DsfrInput"]; + DsfrModal: (typeof import("@gouvminint/vue-dsfr"))["DsfrModal"]; + DsfrPicture: (typeof import("@gouvminint/vue-dsfr"))["DsfrPicture"]; + DsfrRadioButton: (typeof import("@gouvminint/vue-dsfr"))["DsfrRadioButton"]; + DsfrSelect: (typeof import("@gouvminint/vue-dsfr"))["DsfrSelect"]; + DsfrTag: (typeof import("@gouvminint/vue-dsfr"))["DsfrTag"]; + HeaderMain: (typeof import("./components/HeaderMain.vue"))["default"]; + MissingCardAlert: (typeof import("./components/MissingCardAlert.vue"))["default"]; + OnboardingSwiper: (typeof import("./components/OnboardingSwiper.vue"))["default"]; + PopupContact: (typeof import("./components/PopupContact.vue"))["default"]; + PopupVideo: (typeof import("./components/PopupVideo.vue"))["default"]; + ResultPage: (typeof import("./components/ResultPage.vue"))["default"]; + RouterLink: (typeof import("vue-router"))["RouterLink"]; + RouterView: (typeof import("vue-router"))["RouterView"]; + SnackbarAlert: (typeof import("./components/SnackbarAlert.vue"))["default"]; + StepsGuide: (typeof import("./components/StepsGuide.vue"))["default"]; + User: (typeof import("./components/authentication/User.vue"))["default"]; + VIcon: (typeof import("oh-vue-icons"))["OhVueIcon"]; } }