From c6bee32fe5291829d0bbc1d6c8403400cc633bce Mon Sep 17 00:00:00 2001 From: Anass Bouassaba Date: Wed, 17 Jul 2024 20:29:54 +0200 Subject: [PATCH 1/6] wip(language): integrating flake8 linter --- .github/workflows/lint-language.yml | 6 ++-- language/.flake8 | 4 +++ language/README.md | 11 +++++++ language/pdm.lock | 51 ++++++++++++++++++++++++++++- language/pyproject.toml | 5 ++- 5 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 language/.flake8 diff --git a/.github/workflows/lint-language.yml b/.github/workflows/lint-language.yml index df1ed5414..cfbf91eca 100644 --- a/.github/workflows/lint-language.yml +++ b/.github/workflows/lint-language.yml @@ -24,10 +24,10 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - name: Lint using Golanci lint - uses: golangci/golangci-lint-action@v6 + - name: Lint using flake8 + uses: suo/flake8-github-action@releases/v1 with: - working-directory: language + checkName: linting permissions: contents: read pull-requests: read diff --git a/language/.flake8 b/language/.flake8 new file mode 100644 index 000000000..cebe69a0c --- /dev/null +++ b/language/.flake8 @@ -0,0 +1,4 @@ +[flake8] +exclude = .git,.venv,.dockerignore,.pdm-python,Dockerfile +extend-ignore = E203 +max-line-length = 88 \ No newline at end of file diff --git a/language/README.md b/language/README.md index 45ddbbf43..5b103c098 100644 --- a/language/README.md +++ b/language/README.md @@ -40,3 +40,14 @@ flask run --host=0.0.0.0 --port=8084 --debug ``` You can omit the `--debug` flag when not developing. + +Lint code: + +```shell +flake8 . +``` + +Format code: +```shell +black . +``` \ No newline at end of file diff --git a/language/pdm.lock b/language/pdm.lock index 2f1b26082..609efe276 100644 --- a/language/pdm.lock +++ b/language/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "dev"] strategy = ["cross_platform", "inherit_metadata"] lock_version = "4.4.1" -content_hash = "sha256:804107041e2bf570e716191f6376eddf8a90abe2665ecd20928f9940ce5fceb3" +content_hash = "sha256:4958861d10ab3b829c26eb74839cb46af0098e5b79ecd595230b30f8b1cb4c43" [[package]] name = "annotated-types" @@ -182,6 +182,22 @@ files = [ {file = "cymem-2.0.8.tar.gz", hash = "sha256:8fb09d222e21dcf1c7e907dc85cf74501d4cea6c4ed4ac6c9e016f98fb59cbbf"}, ] +[[package]] +name = "flake8" +version = "7.1.0" +requires_python = ">=3.8.1" +summary = "the modular source code checker: pep8 pyflakes and co" +groups = ["dev"] +dependencies = [ + "mccabe<0.8.0,>=0.7.0", + "pycodestyle<2.13.0,>=2.12.0", + "pyflakes<3.3.0,>=3.2.0", +] +files = [ + {file = "flake8-7.1.0-py2.py3-none-any.whl", hash = "sha256:2e416edcc62471a64cea09353f4e7bdba32aeb079b6e360554c659a122b1bc6a"}, + {file = "flake8-7.1.0.tar.gz", hash = "sha256:48a07b626b55236e0fb4784ee69a465fbf59d79eec1f5b4785c3d3bc57d17aa5"}, +] + [[package]] name = "flask" version = "3.0.3" @@ -330,6 +346,17 @@ files = [ {file = "MarkupSafe-2.1.5.tar.gz", hash = "sha256:d283d37a890ba4c1ae73ffadf8046435c76e7bc2247bbb63c00bd1a709c6544b"}, ] +[[package]] +name = "mccabe" +version = "0.7.0" +requires_python = ">=3.6" +summary = "McCabe checker, plugin for flake8" +groups = ["dev"] +files = [ + {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, + {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, +] + [[package]] name = "murmurhash" version = "1.0.10" @@ -430,6 +457,17 @@ files = [ {file = "preshed-3.0.9.tar.gz", hash = "sha256:721863c5244ffcd2651ad0928951a2c7c77b102f4e11a251ad85d37ee7621660"}, ] +[[package]] +name = "pycodestyle" +version = "2.12.0" +requires_python = ">=3.8" +summary = "Python style guide checker" +groups = ["dev"] +files = [ + {file = "pycodestyle-2.12.0-py2.py3-none-any.whl", hash = "sha256:949a39f6b86c3e1515ba1787c2022131d165a8ad271b11370a8819aa070269e4"}, + {file = "pycodestyle-2.12.0.tar.gz", hash = "sha256:442f950141b4f43df752dd303511ffded3a04c2b6fb7f65980574f0c31e6e79c"}, +] + [[package]] name = "pydantic" version = "2.7.4" @@ -488,6 +526,17 @@ files = [ {file = "pydantic_core-2.18.4.tar.gz", hash = "sha256:ec3beeada09ff865c344ff3bc2f427f5e6c26401cc6113d77e372c3fdac73864"}, ] +[[package]] +name = "pyflakes" +version = "3.2.0" +requires_python = ">=3.8" +summary = "passive checker of Python programs" +groups = ["dev"] +files = [ + {file = "pyflakes-3.2.0-py2.py3-none-any.whl", hash = "sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a"}, + {file = "pyflakes-3.2.0.tar.gz", hash = "sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f"}, +] + [[package]] name = "requests" version = "2.32.2" diff --git a/language/pyproject.toml b/language/pyproject.toml index 5e3818f96..1d35e08c8 100644 --- a/language/pyproject.toml +++ b/language/pyproject.toml @@ -6,7 +6,10 @@ requires-python = "==3.12.*" dependencies = ["flask==3.0.3", "spacy==3.7.4", "requests==2.32.2"] [tool.pdm.dev-dependencies] -dev = ["black==24.4.2"] +dev = [ + "black==24.4.2", + "flake8==7.1.0", +] [tool.pdm] distribution = false From c5f92265a344bea5c2ebe0494d0b457236978213 Mon Sep 17 00:00:00 2001 From: Anass Bouassaba Date: Wed, 17 Jul 2024 20:45:58 +0200 Subject: [PATCH 2/6] wip(language): update lint-language.yml --- .github/workflows/lint-language.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/lint-language.yml b/.github/workflows/lint-language.yml index cfbf91eca..0803d71ee 100644 --- a/.github/workflows/lint-language.yml +++ b/.github/workflows/lint-language.yml @@ -24,6 +24,14 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v1 + with: + python-version: 3.12 + + - name: Install flake8 + run: pip install flake8 + - name: Lint using flake8 uses: suo/flake8-github-action@releases/v1 with: From c03c81cafa9c42e0837546d6de814f5b6a70cfd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20=C5=81oboda?= Date: Wed, 17 Jul 2024 20:55:27 +0200 Subject: [PATCH 3/6] ci: removed build on PR --- .github/workflows/build-language.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/build-language.yml b/.github/workflows/build-language.yml index a8fd69a67..c2bf07395 100644 --- a/.github/workflows/build-language.yml +++ b/.github/workflows/build-language.yml @@ -25,11 +25,6 @@ on: - "language/**" tags: - 'v*' - pull_request: - branches: - - main - paths: - - "language/**" jobs: build_and_push: From f41b140eed1acc5c97c88b31ca31d616910fd1e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20=C5=81oboda?= Date: Wed, 17 Jul 2024 20:55:38 +0200 Subject: [PATCH 4/6] ci: python linters --- .github/workflows/lint-language.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint-language.yml b/.github/workflows/lint-language.yml index 0803d71ee..4ebe7b6a2 100644 --- a/.github/workflows/lint-language.yml +++ b/.github/workflows/lint-language.yml @@ -25,7 +25,7 @@ jobs: uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v5 with: python-version: 3.12 @@ -33,9 +33,14 @@ jobs: run: pip install flake8 - name: Lint using flake8 - uses: suo/flake8-github-action@releases/v1 + uses: py-actions/flake8@v2 with: - checkName: linting + path: language + ignore: "E203" + max-line-length: "88" + exclude: ".git,.venv,.dockerignore,.pdm-python,Dockerfile" + plugins: "flake8-black" + permissions: contents: read pull-requests: read From 637819d55e86dec4d95f8910dc81aa721eb9297f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20=C5=81oboda?= Date: Wed, 17 Jul 2024 20:56:06 +0200 Subject: [PATCH 5/6] chore: removed unneded .flake8 file --- language/.flake8 | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 language/.flake8 diff --git a/language/.flake8 b/language/.flake8 deleted file mode 100644 index cebe69a0c..000000000 --- a/language/.flake8 +++ /dev/null @@ -1,4 +0,0 @@ -[flake8] -exclude = .git,.venv,.dockerignore,.pdm-python,Dockerfile -extend-ignore = E203 -max-line-length = 88 \ No newline at end of file From d0f11c54605863bf61fcdfedcf6d8aefb2eb1f51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20=C5=81oboda?= Date: Wed, 17 Jul 2024 20:57:54 +0200 Subject: [PATCH 6/6] ci: removed flake8 installation --- .github/workflows/lint-language.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/lint-language.yml b/.github/workflows/lint-language.yml index 4ebe7b6a2..d917cd1db 100644 --- a/.github/workflows/lint-language.yml +++ b/.github/workflows/lint-language.yml @@ -29,9 +29,6 @@ jobs: with: python-version: 3.12 - - name: Install flake8 - run: pip install flake8 - - name: Lint using flake8 uses: py-actions/flake8@v2 with: