From ca296989281c3545a959bbfd105ebbe1fb94cdce Mon Sep 17 00:00:00 2001 From: J1Loop Date: Wed, 9 Oct 2024 13:21:40 +0200 Subject: [PATCH 1/8] [CH] Remove .pylintrc from gitignore --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index c9f0797..894f047 100644 --- a/.gitignore +++ b/.gitignore @@ -30,5 +30,4 @@ env/ .DS_Store Thumbs.db -.pylintrc -output/ \ No newline at end of file +output/ From f2da51bc63af5acf58f6d8031207e1b1667a1819 Mon Sep 17 00:00:00 2001 From: J1Loop Date: Wed, 9 Oct 2024 13:30:33 +0200 Subject: [PATCH 2/8] [CICD] Add pylint github action --- .github/workflows/.keep | 0 .github/workflows/abc.yml | 34 +++++++++++ .pylintrc | 46 +++++++++++++++ poetry.lock | 115 +++++++++++++++++++++++++++++++++++++- pyproject.toml | 3 + 5 files changed, 197 insertions(+), 1 deletion(-) delete mode 100644 .github/workflows/.keep create mode 100644 .github/workflows/abc.yml create mode 100644 .pylintrc diff --git a/.github/workflows/.keep b/.github/workflows/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/.github/workflows/abc.yml b/.github/workflows/abc.yml new file mode 100644 index 0000000..f453aa3 --- /dev/null +++ b/.github/workflows/abc.yml @@ -0,0 +1,34 @@ +name: Pylint Check + +on: + pull_request: + branches: + - dev + workflow_dispatch: + +jobs: + pylint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.12' + + - name: Install dependencies + run: | + pip install poetry + poetry install + + - name: Run pylint + run: | + pylint_score=$(pylint src/ | grep 'Your code has been rated at' | awk '{print $7}' | cut -d '/' -f 1) + if (( $(echo "$pylint_score < 9.5" | bc -l) )); then + echo "Pylint score is too low: $pylint_score. Minimum required: 9.5" + exit 1 + else + echo "Pylint score is $pylint_score. Passed!" + fi diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..c771fcd --- /dev/null +++ b/.pylintrc @@ -0,0 +1,46 @@ +[MASTER] +# AƱade directorios a la lista de Python Path, separados por comas. +init-hook='import sys; sys.path.append("YOUR PATH")' + +[BASIC] +good-names=Hermes + +[MESSAGES CONTROL] +disable= + too-many-locals, + too-many-arguments, + too-few-public-methods, + missing-module-docstring, + ; missing-class-docstring, + ; missing-function-docstring, + unspecified-encoding, + anomalous-backslash-in-string + +[FORMAT] +max-line-length=88 +indent-string=' ' +ignore-long-lines=^(\s*#.*|\s*print\(.*|\s*https?:\/\/[^\s]+|\s*def .+\(.*\):|\s*if .+:)$ + +[DESIGN] +max-args=5 +max-locals=15 +max-returns=6 +max-branches=12 +max-statements=50 +max-parents=7 +max-attributes=7 + +[TYPECHECK] +ignored-modules=flask_sqlalchemy,sqlalchemy,sqlalchemy.orm,flask_marshmallow,marshmallow + +[REPORTS] +reports=no + +[LOGGING] +disable=logging-format-interpolation,logging-not-lazy + +[IMPORTS] +disable=import-error,ungrouped-imports + +[SIMILARITIES] +min-similarity-lines=4 diff --git a/poetry.lock b/poetry.lock index 0f35faa..42695a9 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,5 +1,16 @@ # This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +[[package]] +name = "astroid" +version = "3.3.5" +description = "An abstract syntax tree for Python with inference support." +optional = false +python-versions = ">=3.9.0" +files = [ + {file = "astroid-3.3.5-py3-none-any.whl", hash = "sha256:a9d1c946ada25098d790e079ba2a1b112157278f3fb7e718ae6a9252f5835dc8"}, + {file = "astroid-3.3.5.tar.gz", hash = "sha256:5cfc40ae9f68311075d27ef68a4841bdc5cc7f6cf86671b49f00607d30188e2d"}, +] + [[package]] name = "bcrypt" version = "4.2.0" @@ -288,6 +299,17 @@ files = [ [package.dependencies] pycparser = "*" +[[package]] +name = "colorama" +version = "0.4.6" +description = "Cross-platform colored terminal text." +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +files = [ + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] + [[package]] name = "cryptography" version = "43.0.1" @@ -356,6 +378,21 @@ webencodings = "*" doc = ["sphinx", "sphinx_rtd_theme"] test = ["flake8", "isort", "pytest"] +[[package]] +name = "dill" +version = "0.3.9" +description = "serialize all of Python" +optional = false +python-versions = ">=3.8" +files = [ + {file = "dill-0.3.9-py3-none-any.whl", hash = "sha256:468dff3b89520b474c0397703366b7b95eebe6303f108adf9b19da1f702be87a"}, + {file = "dill-0.3.9.tar.gz", hash = "sha256:81aa267dddf68cbfe8029c42ca9ec6a4ab3b22371d1c450abc54422577b4512c"}, +] + +[package.extras] +graph = ["objgraph (>=1.7.2)"] +profile = ["gprof2dot (>=2022.7.29)"] + [[package]] name = "fonttools" version = "4.54.1" @@ -453,6 +490,20 @@ chardet = ["chardet (>=2.2)"] genshi = ["genshi"] lxml = ["lxml"] +[[package]] +name = "isort" +version = "5.13.2" +description = "A Python utility / library to sort Python imports." +optional = false +python-versions = ">=3.8.0" +files = [ + {file = "isort-5.13.2-py3-none-any.whl", hash = "sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6"}, + {file = "isort-5.13.2.tar.gz", hash = "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109"}, +] + +[package.extras] +colors = ["colorama (>=0.4.6)"] + [[package]] name = "jmespath" version = "1.0.1" @@ -464,6 +515,17 @@ files = [ {file = "jmespath-1.0.1.tar.gz", hash = "sha256:90261b206d6defd58fdd5e85f478bf633a2901798906be2ad389150c5c60edbe"}, ] +[[package]] +name = "mccabe" +version = "0.7.0" +description = "McCabe checker, plugin for flake8" +optional = false +python-versions = ">=3.6" +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 = "numpy" version = "2.1.2" @@ -726,6 +788,22 @@ tests = ["check-manifest", "coverage", "defusedxml", "markdown2", "olefile", "pa typing = ["typing-extensions"] xmp = ["defusedxml"] +[[package]] +name = "platformdirs" +version = "4.3.6" +description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`." +optional = false +python-versions = ">=3.8" +files = [ + {file = "platformdirs-4.3.6-py3-none-any.whl", hash = "sha256:73e575e1408ab8103900836b97580d5307456908a03e92031bab39e4554cc3fb"}, + {file = "platformdirs-4.3.6.tar.gz", hash = "sha256:357fb2acbc885b0419afd3ce3ed34564c13c9b95c89360cd9563f73aa5e2b907"}, +] + +[package.extras] +docs = ["furo (>=2024.8.6)", "proselint (>=0.14)", "sphinx (>=8.0.2)", "sphinx-autodoc-typehints (>=2.4)"] +test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=8.3.2)", "pytest-cov (>=5)", "pytest-mock (>=3.14)"] +type = ["mypy (>=1.11.2)"] + [[package]] name = "psycopg" version = "3.2.3" @@ -789,6 +867,30 @@ files = [ doc = ["sphinx", "sphinx_rtd_theme"] test = ["pillow", "pytest", "ruff"] +[[package]] +name = "pylint" +version = "3.3.1" +description = "python code static checker" +optional = false +python-versions = ">=3.9.0" +files = [ + {file = "pylint-3.3.1-py3-none-any.whl", hash = "sha256:2f846a466dd023513240bc140ad2dd73bfc080a5d85a710afdb728c420a5a2b9"}, + {file = "pylint-3.3.1.tar.gz", hash = "sha256:9f3dcc87b1203e612b78d91a896407787e708b3f189b5fa0b307712d49ff0c6e"}, +] + +[package.dependencies] +astroid = ">=3.3.4,<=3.4.0-dev0" +colorama = {version = ">=0.4.5", markers = "sys_platform == \"win32\""} +dill = {version = ">=0.3.7", markers = "python_version >= \"3.12\""} +isort = ">=4.2.5,<5.13.0 || >5.13.0,<6" +mccabe = ">=0.6,<0.8" +platformdirs = ">=2.2.0" +tomlkit = ">=0.10.1" + +[package.extras] +spelling = ["pyenchant (>=3.2,<4.0)"] +testutils = ["gitpython (>3)"] + [[package]] name = "pynacl" version = "1.5.0" @@ -901,6 +1003,17 @@ webencodings = ">=0.4" doc = ["sphinx", "sphinx_rtd_theme"] test = ["pytest", "ruff"] +[[package]] +name = "tomlkit" +version = "0.13.2" +description = "Style preserving TOML library" +optional = false +python-versions = ">=3.8" +files = [ + {file = "tomlkit-0.13.2-py3-none-any.whl", hash = "sha256:7a974427f6e119197f670fbbbeae7bef749a6c14e793db934baefc1b5f03efde"}, + {file = "tomlkit-0.13.2.tar.gz", hash = "sha256:fff5fe59a87295b278abd31bec92c15d9bc4a06885ab12bcea52c71119392e79"}, +] + [[package]] name = "typing-extensions" version = "4.12.2" @@ -1052,4 +1165,4 @@ test = ["pytest"] [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "4709a803835d1acfa315ff9d4d2adcb9b738facb4a6478b36be8eb6bb1498621" +content-hash = "109e1c93dd99c026968ac637c2011163fa1cef9848de32f0cee07545ab573c5e" diff --git a/pyproject.toml b/pyproject.toml index 914c669..7292d88 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,6 +16,9 @@ pandas = "^2.2.3" psycopg = "^3.2.3" psycopg-pool = "^3.2.3" +[tool.poetry.group.dev.dependencies] +pylint = "^3.3.1" + [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" From 85a91da2179b0dd2a5e2e9158862fa055aa92e86 Mon Sep 17 00:00:00 2001 From: J1Loop Date: Wed, 9 Oct 2024 13:35:41 +0200 Subject: [PATCH 3/8] [CICD] Remove poetry to install pylint directly --- .github/workflows/abc.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/abc.yml b/.github/workflows/abc.yml index f453aa3..e04d897 100644 --- a/.github/workflows/abc.yml +++ b/.github/workflows/abc.yml @@ -5,7 +5,7 @@ on: branches: - dev workflow_dispatch: - + jobs: pylint: runs-on: ubuntu-latest @@ -18,10 +18,9 @@ jobs: with: python-version: '3.12' - - name: Install dependencies + - name: Install pylint run: | - pip install poetry - poetry install + pip install pylint - name: Run pylint run: | From 80dc8feec6a377a2012a8ec539fb63b31a567539 Mon Sep 17 00:00:00 2001 From: J1Loop Date: Wed, 9 Oct 2024 13:50:30 +0200 Subject: [PATCH 4/8] [CICD] Add PR comment --- .github/not_enough_pylint_score.md | 27 +++++++++++++++++++++++ .github/workflows/{abc.yml => pylint.yml} | 13 ++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 .github/not_enough_pylint_score.md rename .github/workflows/{abc.yml => pylint.yml} (65%) diff --git a/.github/not_enough_pylint_score.md b/.github/not_enough_pylint_score.md new file mode 100644 index 0000000..faf3bad --- /dev/null +++ b/.github/not_enough_pylint_score.md @@ -0,0 +1,27 @@ +**With so many valid branch prefixes, and yet somehow, you managed to get it wrong. Spectacular.** + +This PR is being closed automatically due to not scoring enough on the Pylint test. Please fix enough issues and reopen the PR. + +### Valid branch prefixes are: +- ft/ +- feat/ +- feature/ +- pt/ +- patch/ +- ft-patch +- fx/ +- fix/ +- rf/ +- ref/ +- refactor/ + +### To rename your branch, follow these steps: +1. Rename the branch locally: + ``` + git branch -m + ``` +2. Push the renamed branch and set the upstream: + ``` + git push -u origin + ``` +3. Reopen the PR. \ No newline at end of file diff --git a/.github/workflows/abc.yml b/.github/workflows/pylint.yml similarity index 65% rename from .github/workflows/abc.yml rename to .github/workflows/pylint.yml index e04d897..dbc870f 100644 --- a/.github/workflows/abc.yml +++ b/.github/workflows/pylint.yml @@ -4,11 +4,12 @@ on: pull_request: branches: - dev + - main workflow_dispatch: jobs: pylint: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: Checkout code uses: actions/checkout@v4 @@ -19,14 +20,20 @@ jobs: python-version: '3.12' - name: Install pylint - run: | - pip install pylint + run: pip install pylint - name: Run pylint + env: + GH_TOKEN: ${{ github.token }} + shell: bash run: | pylint_score=$(pylint src/ | grep 'Your code has been rated at' | awk '{print $7}' | cut -d '/' -f 1) if (( $(echo "$pylint_score < 9.5" | bc -l) )); then echo "Pylint score is too low: $pylint_score. Minimum required: 9.5" + gh pr comment \ + ${{ github.event.pull_request.number }} \ + --body "Failed! Pylint score is too low: $pylint_score. Minimum required: 9.5" + # --body "$(cat .github/not_enough_pylint_score.md)" exit 1 else echo "Pylint score is $pylint_score. Passed!" From e4a86d4809f9c970609d6298a85584617bfa1319 Mon Sep 17 00:00:00 2001 From: J1Loop Date: Wed, 9 Oct 2024 14:03:42 +0200 Subject: [PATCH 5/8] [CICD] Add fail markdown message. --- .github/not_enough_pylint_score.md | 51 ++++++++++++++---------------- .github/workflows/pylint.yml | 4 +-- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/.github/not_enough_pylint_score.md b/.github/not_enough_pylint_score.md index faf3bad..edc252c 100644 --- a/.github/not_enough_pylint_score.md +++ b/.github/not_enough_pylint_score.md @@ -1,27 +1,24 @@ -**With so many valid branch prefixes, and yet somehow, you managed to get it wrong. Spectacular.** - -This PR is being closed automatically due to not scoring enough on the Pylint test. Please fix enough issues and reopen the PR. - -### Valid branch prefixes are: -- ft/ -- feat/ -- feature/ -- pt/ -- patch/ -- ft-patch -- fx/ -- fix/ -- rf/ -- ref/ -- refactor/ - -### To rename your branch, follow these steps: -1. Rename the branch locally: - ``` - git branch -m - ``` -2. Push the renamed branch and set the upstream: - ``` - git push -u origin - ``` -3. Reopen the PR. \ No newline at end of file +_**Out of all the ways to write clean code, you really went and chose not to. Impressive choice!**_ + +## :warning: Pylint Check Failed :warning: + +### Pylint Score: **{{pylint_score}}** + +#### Minimum required score: **9.5** + +It looks like your recent code changes did not meet the required Pylint score of **9.5**. Please review the Pylint output and make the necessary adjustments to improve code quality. + +#### What you can do: +- **Review the Pylint report** to identify areas of your code that need improvement. +- **Refactor** sections that are lowering your score, focusing on issues like code complexity, formatting, or coding standards. +- Once changes are made, **push** your updates to the same pull request to trigger another check. + +Remember, maintaining a high Pylint score helps ensure code readability, maintainability, and consistency across the project. + +You can find our project's Pylint configuration in the [`.pylintrc`](../.pylintrc) file. + +Feel free to reach out if you need help with any specific issue! + +--- + +This automated message was triggered by a failed Pylint check. diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index dbc870f..169fdcb 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -32,8 +32,8 @@ jobs: echo "Pylint score is too low: $pylint_score. Minimum required: 9.5" gh pr comment \ ${{ github.event.pull_request.number }} \ - --body "Failed! Pylint score is too low: $pylint_score. Minimum required: 9.5" - # --body "$(cat .github/not_enough_pylint_score.md)" + # --body "Failed! Pylint score is too low: $pylint_score. Minimum required: 9.5" + --body "$(cat .github/not_enough_pylint_score.md)" exit 1 else echo "Pylint score is $pylint_score. Passed!" From 98762a684a2306605b9ea3624eff1a7e3d84e386 Mon Sep 17 00:00:00 2001 From: J1Loop Date: Wed, 9 Oct 2024 14:07:21 +0200 Subject: [PATCH 6/8] [CICD] Minor fixes --- .github/workflows/pylint.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 169fdcb..f73446e 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -32,7 +32,6 @@ jobs: echo "Pylint score is too low: $pylint_score. Minimum required: 9.5" gh pr comment \ ${{ github.event.pull_request.number }} \ - # --body "Failed! Pylint score is too low: $pylint_score. Minimum required: 9.5" --body "$(cat .github/not_enough_pylint_score.md)" exit 1 else From e41ae8bf7ab04bf5d353064bab93e5070afac93a Mon Sep 17 00:00:00 2001 From: J1Loop Date: Wed, 9 Oct 2024 14:08:41 +0200 Subject: [PATCH 7/8] [CICD] Minor fixes 2 --- .github/workflows/pylint.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index f73446e..9a5def8 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -30,6 +30,9 @@ jobs: pylint_score=$(pylint src/ | grep 'Your code has been rated at' | awk '{print $7}' | cut -d '/' -f 1) if (( $(echo "$pylint_score < 9.5" | bc -l) )); then echo "Pylint score is too low: $pylint_score. Minimum required: 9.5" + + cat .github/not_enough_pylint_score.md + gh pr comment \ ${{ github.event.pull_request.number }} \ --body "$(cat .github/not_enough_pylint_score.md)" From 66e006e550dbd7af031b9e21fd90c243aca09c00 Mon Sep 17 00:00:00 2001 From: J1Loop Date: Wed, 9 Oct 2024 15:32:07 +0200 Subject: [PATCH 8/8] [CICD] Minor fixes 3 --- .github/workflows/pylint.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 9a5def8..ef5f4c1 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -25,7 +25,6 @@ jobs: - name: Run pylint env: GH_TOKEN: ${{ github.token }} - shell: bash run: | pylint_score=$(pylint src/ | grep 'Your code has been rated at' | awk '{print $7}' | cut -d '/' -f 1) if (( $(echo "$pylint_score < 9.5" | bc -l) )); then