From 83af1129bee555bd2a4e72db989392c15fd20e22 Mon Sep 17 00:00:00 2001 From: ripplefcl Date: Fri, 22 Mar 2024 11:38:46 +0000 Subject: [PATCH 01/28] excluded dirs from flake8 linting --- .flake8 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.flake8 b/.flake8 index 0d579403..0572553c 100644 --- a/.flake8 +++ b/.flake8 @@ -1,4 +1,7 @@ [flake8] max-line-length = 127 extend-ignore = E203, W503 -max-complexity = 10 \ No newline at end of file +max-complexity = 10 +exclude = + __pycache__ + .venv From 7f5b69c86393fabc3ac159f5b2aeb54fc955ded7 Mon Sep 17 00:00:00 2001 From: ripplefcl Date: Fri, 22 Mar 2024 11:54:19 +0000 Subject: [PATCH 02/28] switched to autopep8 modified: requirements-ci.txt modified: .github/workflows/ci.yml --- .github/workflows/ci.yml | 15 +++++++++------ requirements-ci.txt | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5b2b71c..522ebfad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,25 +17,25 @@ jobs: # exit-zero treats all errors as warnings flake8 . --format="::warning file=%(path)s,line=%(row)d,col=%(col)d::%(text)s" --exit-zero --max-complexity=10 - lint-black: + lint-pylint: runs-on: ubuntu-latest steps: - name: Checkout the repository at the current branch uses: actions/checkout@v2 - name: Install dependencies uses: ./.github/actions/setup - - name: Lint with black - run: black --diff . + - name: Lint with pylint + run: pylint --msg-template='::warning file={path},line={line},col={column}::{msg}' */ || exit 0 - lint-pylint: + lint-autopep8: runs-on: ubuntu-latest steps: - name: Checkout the repository at the current branch uses: actions/checkout@v2 - name: Install dependencies uses: ./.github/actions/setup - - name: Lint with pylint - run: pylint --msg-template='::warning file={path},line={line},col={column}::{msg}' */ || exit 0 + - name: Lint with autopep8 + run: autopep8 --recursive --diff --exclude ".venv/**" . lint-isort: runs-on: ubuntu-latest @@ -47,6 +47,9 @@ jobs: - name: Lint with isort run: isort --check --diff . + + + check-json: runs-on: ubuntu-latest steps: diff --git a/requirements-ci.txt b/requirements-ci.txt index 9627d8e4..4fd722f5 100644 --- a/requirements-ci.txt +++ b/requirements-ci.txt @@ -1,4 +1,4 @@ -black +autopep8 flake8 pylint isort From 33c1af97be76b87b2cf64c9355f939be53c48959 Mon Sep 17 00:00:00 2001 From: ripplefcl Date: Fri, 22 Mar 2024 12:03:40 +0000 Subject: [PATCH 03/28] fixed pylint pipeline --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 522ebfad..8d649ee3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: - name: Install dependencies uses: ./.github/actions/setup - name: Lint with pylint - run: pylint --msg-template='::warning file={path},line={line},col={column}::{msg}' */ || exit 0 + run: pylint --msg-template='::({category}) file={path},line={line},col={column}::{msg}' *; if [ $(( $? & 2 )) -eq 2 ] || [ $(( $? & 1 )) -eq 1 ] ; then exit 1; else exit 0; fi lint-autopep8: runs-on: ubuntu-latest From 4796edb0e223d0d05f80e95264722913e043ec67 Mon Sep 17 00:00:00 2001 From: ripplefcl Date: Fri, 22 Mar 2024 12:11:14 +0000 Subject: [PATCH 04/28] fixed linting command issues --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8d649ee3..38b26f0e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: - name: Install dependencies uses: ./.github/actions/setup - name: Lint with pylint - run: pylint --msg-template='::({category}) file={path},line={line},col={column}::{msg}' *; if [ $(( $? & 2 )) -eq 2 ] || [ $(( $? & 1 )) -eq 1 ] ; then exit 1; else exit 0; fi + run: find . -type f -name "*.py" | pylint --msg-template='::({category}) file={path},line={line},col={column}::{msg}'; if [ $(( $? & 2 )) -eq 2 ] || [ $(( $? & 1 )) -eq 1 ] ; then exit 1; else exit 0; fi lint-autopep8: runs-on: ubuntu-latest From a1d67f65ca3939917beda5539a8051427854deb3 Mon Sep 17 00:00:00 2001 From: ripplefcl Date: Fri, 22 Mar 2024 12:14:57 +0000 Subject: [PATCH 05/28] forgot xargs and removed venv from linting --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 38b26f0e..2893b76a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: - name: Install dependencies uses: ./.github/actions/setup - name: Lint with pylint - run: find . -type f -name "*.py" | pylint --msg-template='::({category}) file={path},line={line},col={column}::{msg}'; if [ $(( $? & 2 )) -eq 2 ] || [ $(( $? & 1 )) -eq 1 ] ; then exit 1; else exit 0; fi + run: find . -type f -name "*.py" -not -path "*.venv/*" | xargs pylint --msg-template='::({category}) file={path},line={line},col={column}::{msg}'; if [ $(( $? & 2 )) -eq 2 ] || [ $(( $? & 1 )) -eq 1 ] ; then exit 1; else exit 0; fi lint-autopep8: runs-on: ubuntu-latest From 4dcd723908c3dbcb8da92b219fb4464e06df8c77 Mon Sep 17 00:00:00 2001 From: ripplefcl Date: Fri, 22 Mar 2024 13:46:54 +0000 Subject: [PATCH 06/28] fixed styling --- .github/workflows/ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2893b76a..b79f4593 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,9 +47,6 @@ jobs: - name: Lint with isort run: isort --check --diff . - - - check-json: runs-on: ubuntu-latest steps: From 64978edc16d09cd7ff78807f21d948e0fa514edc Mon Sep 17 00:00:00 2001 From: ripple Date: Fri, 3 May 2024 12:17:04 +0100 Subject: [PATCH 07/28] made flake8 play nice with black --- .flake8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.flake8 b/.flake8 index 0572553c..47165198 100644 --- a/.flake8 +++ b/.flake8 @@ -1,6 +1,6 @@ [flake8] max-line-length = 127 -extend-ignore = E203, W503 +extend-ignore = E203, E701, W503 max-complexity = 10 exclude = __pycache__ From 2aa46536ee57ba927b0bcfe657602e84756c04f2 Mon Sep 17 00:00:00 2001 From: ripple Date: Fri, 3 May 2024 12:26:18 +0100 Subject: [PATCH 08/28] version locked ci deps --- requirements-ci.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/requirements-ci.txt b/requirements-ci.txt index 4fd722f5..06e48b1f 100644 --- a/requirements-ci.txt +++ b/requirements-ci.txt @@ -1,8 +1,8 @@ -autopep8 -flake8 -pylint -isort -fastjsonschema -pytest -pytest-asyncio -pytest-aiohttp +autopep8==2.1.0 +flake8==7.0.0 +pylint==3.1.0 +isort==5.13.2 +fastjsonschema==2.19.1 +pytest==8.2.0 +pytest-asyncio==0.23.6 +pytest-aiohttp==1.0.5 From ea5c37dc38785f1977ef37af6401044db918e647 Mon Sep 17 00:00:00 2001 From: ripple Date: Fri, 3 May 2024 12:51:58 +0100 Subject: [PATCH 09/28] added black pre-commit hook --- .pre-commit-config.yaml | 5 +++++ requirements-dev.txt | 1 + 2 files changed, 6 insertions(+) create mode 100644 .pre-commit-config.yaml create mode 100644 requirements-dev.txt diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..9d4b1159 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,5 @@ +repos: + - repo: https://github.com/psf/black + rev: 24.4.2 + hooks: + - id: black diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 00000000..416634f5 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1 @@ +pre-commit From 9dba346b9490f4835776054072d731a031ff1f75 Mon Sep 17 00:00:00 2001 From: ripple Date: Fri, 3 May 2024 12:58:40 +0100 Subject: [PATCH 10/28] added other linter/formaters and version locked deps --- .pre-commit-config.yaml | 17 +++++++++++++++++ requirements-dev.txt | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9d4b1159..eb3153a6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,3 +3,20 @@ repos: rev: 24.4.2 hooks: - id: black + - repo: https://github.com/pycqa/isort + rev: 5.13.2 + hooks: + - id: isort + name: isort (python) + - repo: local + hooks: + - id: pylint + name: pylint + entry: pylint + language: system + types: [python] + args: + [ + "-rn", # Only display messages + "-sn", # Don't display the score + ] diff --git a/requirements-dev.txt b/requirements-dev.txt index 416634f5..bc5e3999 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1 +1,2 @@ -pre-commit +pre-commit==3.7.0 +pylint==3.1.0 From e4f5d04049d1419b0a495a688b2509ab63d06ab7 Mon Sep 17 00:00:00 2001 From: ripple Date: Fri, 3 May 2024 13:03:23 +0100 Subject: [PATCH 11/28] reordered hooks and enabled fail fast --- .pre-commit-config.yaml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index eb3153a6..3309a544 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,13 +1,6 @@ +fail_fast: true + repos: - - repo: https://github.com/psf/black - rev: 24.4.2 - hooks: - - id: black - - repo: https://github.com/pycqa/isort - rev: 5.13.2 - hooks: - - id: isort - name: isort (python) - repo: local hooks: - id: pylint @@ -20,3 +13,12 @@ repos: "-rn", # Only display messages "-sn", # Don't display the score ] + - repo: https://github.com/psf/black + rev: 24.4.2 + hooks: + - id: black + - repo: https://github.com/pycqa/isort + rev: 5.13.2 + hooks: + - id: isort + name: isort (python) From 3d5bd99b2009b2770a2c99f6418ed242856b03ee Mon Sep 17 00:00:00 2001 From: ripple Date: Fri, 3 May 2024 13:48:19 +0100 Subject: [PATCH 12/28] changed docs --- README.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 8274fccb..ebb194c8 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ This cog displays the number of users banned in the guild with a random selectio - `[p]bancount` - Displays the total ban count using a randomly selected message. - `[p]bancount list` - Lists all the messages that can be used in the guild. - `[p]bancount add ` - Add a message to the guild list. Use `$ban` to insert the ban count in the message. -- `[p]bancount remove ` - Deletes (by index, from the list command) the message from the guild list. +- `[p]bancount remove ` - Deletes (by index, from the list command) the message from the guild list. ### BetterPing @@ -421,14 +421,11 @@ Copyright (c) 2018-2023 tigattack, contributors and original authors. The CI will fail unless your code is [PEP8](https://www.python.org/dev/peps/pep-0008/) compliant. ```bash -pip install -r requirements-ci.txt -isort . # This will fix the order of imports -black . # This will auto-format and fix a lot of common mistakes -pylint * # This will show general pep8-violations +pip install -r requirements-dev.txt -r requirements.txt +pre-commit install +pre-commit run --all-file ``` -If you use [VSCode](https://code.visualstudio.com/) you can use the tasks integrated into the repo to locally run the same tasks as our CI - ### Making changes When suggesting changes, please [open an issue](https://github.com/rHomelab/LabBot-Cogs/issues/new/choose) so it can be reviewed by the team who can then suggest how and if the idea is to be implemented. From 9bec303ed7dae0974b319af193eb9d6c9f049c52 Mon Sep 17 00:00:00 2001 From: ripple Date: Fri, 3 May 2024 14:08:56 +0100 Subject: [PATCH 13/28] moved requirements file --- .github/actions/setup/action.yml | 2 +- requirements-ci.txt => .github/requirements-ci.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename requirements-ci.txt => .github/requirements-ci.txt (72%) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index d2828658..602e5e12 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -12,7 +12,7 @@ runs: run: pip install --quiet --upgrade --requirement requirements.txt - name: Install CI dependencies shell: bash - run: pip install --quiet --upgrade --requirement requirements-ci.txt + run: pip install --quiet --upgrade --requirement .github/requirements-ci.txt - name: Install cog dependencies shell: bash run: | diff --git a/requirements-ci.txt b/.github/requirements-ci.txt similarity index 72% rename from requirements-ci.txt rename to .github/requirements-ci.txt index 06e48b1f..a108c623 100644 --- a/requirements-ci.txt +++ b/.github/requirements-ci.txt @@ -1,8 +1,8 @@ -autopep8==2.1.0 +black==24.4.2 flake8==7.0.0 pylint==3.1.0 isort==5.13.2 fastjsonschema==2.19.1 pytest==8.2.0 pytest-asyncio==0.23.6 -pytest-aiohttp==1.0.5 +pytest-aiohttp==1.0.5 From fbd724c6605505a293d9d437f76cc7caa15f5cbc Mon Sep 17 00:00:00 2001 From: ripple Date: Fri, 3 May 2024 14:16:47 +0100 Subject: [PATCH 14/28] included vscode extention in tge readme and fixed typo --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ebb194c8..258417df 100644 --- a/README.md +++ b/README.md @@ -423,9 +423,10 @@ The CI will fail unless your code is [PEP8](https://www.python.org/dev/peps/pep- ```bash pip install -r requirements-dev.txt -r requirements.txt pre-commit install -pre-commit run --all-file +pre-commit run --all-files ``` +If you use [VSCode](https://code.visualstudio.com/) you can [use](https://marketplace.visualstudio.com/items?itemName=MarkLarah.pre-commit-vscode) to auto generate tasks for the pre-commit hooks ### Making changes When suggesting changes, please [open an issue](https://github.com/rHomelab/LabBot-Cogs/issues/new/choose) so it can be reviewed by the team who can then suggest how and if the idea is to be implemented. From 6390b4f34a850ac444252caed8582b04521097dd Mon Sep 17 00:00:00 2001 From: ripple Date: Fri, 3 May 2024 14:20:28 +0100 Subject: [PATCH 15/28] added missing dependencie --- .github/requirements-ci.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/requirements-ci.txt b/.github/requirements-ci.txt index a108c623..08a98c26 100644 --- a/.github/requirements-ci.txt +++ b/.github/requirements-ci.txt @@ -6,3 +6,4 @@ fastjsonschema==2.19.1 pytest==8.2.0 pytest-asyncio==0.23.6 pytest-aiohttp==1.0.5 +autopep8==2.1.0 From 943acb6260bdaa33b177c893188b0f215d5486dc Mon Sep 17 00:00:00 2001 From: ripple Date: Fri, 3 May 2024 14:22:17 +0100 Subject: [PATCH 16/28] fixed typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 258417df..d99e11a5 100644 --- a/README.md +++ b/README.md @@ -426,7 +426,7 @@ pre-commit install pre-commit run --all-files ``` -If you use [VSCode](https://code.visualstudio.com/) you can [use](https://marketplace.visualstudio.com/items?itemName=MarkLarah.pre-commit-vscode) to auto generate tasks for the pre-commit hooks +If you use [VSCode](https://code.visualstudio.com/) you can use this [extention](https://marketplace.visualstudio.com/items?itemName=MarkLarah.pre-commit-vscode) to auto generate tasks for the pre-commit hooks ### Making changes When suggesting changes, please [open an issue](https://github.com/rHomelab/LabBot-Cogs/issues/new/choose) so it can be reviewed by the team who can then suggest how and if the idea is to be implemented. From 22962e2869ab700d69adb1876e7a8c986e304452 Mon Sep 17 00:00:00 2001 From: ripple Date: Fri, 3 May 2024 15:19:28 +0100 Subject: [PATCH 17/28] removed reduandant tasks --- .vscode/tasks.json | 109 --------------------------------------------- 1 file changed, 109 deletions(-) delete mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index 6e0e6ba8..00000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,109 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "Install task requirements", - "type": "process", - "command": "python3", - "args": [ - "-m", - "pip", - "install", - "--requirement", - "requirements-ci.txt", - "--quiet" - ] - }, - { - "label": "Flake8", - "type": "shell", - "dependsOn": "Install task requirements", - "command": "flake8", - "args": [ - ".", - "--format=\"%(path)s:%(row)d:%(col)d %(text)s\"", - "--exit-zero", - "--max-complexity=10", - "--max-line-length=127" - ], - "problemMatcher": { - "fileLocation": [ - "relative", - "${workspaceFolder}" - ], - "pattern": { - "regexp": "^(.*):(\\d+):(\\d+) (.*)$", - "file": 1, - "line": 2, - "column": 3, - "message": 4 - } - } - }, - { - "label": "Lint with Pylint", - "type": "shell", - "dependsOn": "Install task requirements", - "command": "pylint", - "args": [ - "--msg-template='error {path}:{line}:{column} {msg}'", - "*/" - ], - "problemMatcher": { - "fileLocation": [ - "relative", - "${workspaceFolder}" - ], - "pattern": { - "regexp": "^(error|warning) (.*):(\\d+):(\\d+) (.*)$", - "severity": 1, - "file": 2, - "line": 3, - "column": 4, - "message": 5 - } - } - }, - { - "label": "Format with Black", - "type": "shell", - "dependsOn": "Install task requirements", - "command": "black", - "args": [ - "." - ], - "problemMatcher": [] - }, - { - "label": "Sort imports with isort", - "type": "process", - "dependsOn": "Install task requirements", - "command": "isort", - "args": [ - "." - ] - }, - { - "label": "Check info.json files", - "type": "shell", - "dependsOn": "Install task requirements", - "command": "python3", - "args": [ - ".github/scripts/json_checker.py" - ], - "problemMatcher": { - "fileLocation": [ - "relative", - "${workspaceFolder}" - ], - "pattern": { - "regexp": "^(.*):(\\d+):(\\d+) (.*)$", - "file": 1, - "line": 2, - "column": 3, - "message": 4 - } - } - } - ] -} \ No newline at end of file From fecf4115ff1a434cda52dd4d49f076627a09ef83 Mon Sep 17 00:00:00 2001 From: ripple Date: Fri, 3 May 2024 15:20:57 +0100 Subject: [PATCH 18/28] return to form --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b79f4593..8c2fd485 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,15 +27,15 @@ jobs: - name: Lint with pylint run: find . -type f -name "*.py" -not -path "*.venv/*" | xargs pylint --msg-template='::({category}) file={path},line={line},col={column}::{msg}'; if [ $(( $? & 2 )) -eq 2 ] || [ $(( $? & 1 )) -eq 1 ] ; then exit 1; else exit 0; fi - lint-autopep8: + lint-black: runs-on: ubuntu-latest steps: - name: Checkout the repository at the current branch uses: actions/checkout@v2 - name: Install dependencies uses: ./.github/actions/setup - - name: Lint with autopep8 - run: autopep8 --recursive --diff --exclude ".venv/**" . + - name: Lint with black + run: black --diff . lint-isort: runs-on: ubuntu-latest From 7c4f66fdc6797ef6ef1b69f23768fb721200ed7e Mon Sep 17 00:00:00 2001 From: rippleFCL Date: Fri, 3 May 2024 15:21:55 +0100 Subject: [PATCH 19/28] fixed typo in readme Co-authored-by: tigattack <10629864+tigattack@users.noreply.github.com> --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d99e11a5..a48b1719 100644 --- a/README.md +++ b/README.md @@ -426,7 +426,8 @@ pre-commit install pre-commit run --all-files ``` -If you use [VSCode](https://code.visualstudio.com/) you can use this [extention](https://marketplace.visualstudio.com/items?itemName=MarkLarah.pre-commit-vscode) to auto generate tasks for the pre-commit hooks +If you use [VSCode](https://code.visualstudio.com/) you can use the [pre-commit-vscode](https://marketplace.visualstudio.com/items?itemName=MarkLarah.pre-commit-vscode) extension to auto generate tasks for the pre-commit hooks + ### Making changes When suggesting changes, please [open an issue](https://github.com/rHomelab/LabBot-Cogs/issues/new/choose) so it can be reviewed by the team who can then suggest how and if the idea is to be implemented. From 641108f950beac5a54cccef952483416b0683fcd Mon Sep 17 00:00:00 2001 From: ripple Date: Fri, 3 May 2024 15:30:05 +0100 Subject: [PATCH 20/28] removed my stupidity and improved logging --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c2fd485..7e88613a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: - name: Install dependencies uses: ./.github/actions/setup - name: Lint with pylint - run: find . -type f -name "*.py" -not -path "*.venv/*" | xargs pylint --msg-template='::({category}) file={path},line={line},col={column}::{msg}'; if [ $(( $? & 2 )) -eq 2 ] || [ $(( $? & 1 )) -eq 1 ] ; then exit 1; else exit 0; fi + run: find . -type f -name "*.py" | xargs pylint --msg-template='::{category} file={path},line={line},col={column}::{msg}'; if [ $(( $? & 2 )) -eq 2 ] || [ $(( $? & 1 )) -eq 1 ] ; then exit 1; else exit 0; fi lint-black: runs-on: ubuntu-latest @@ -35,7 +35,7 @@ jobs: - name: Install dependencies uses: ./.github/actions/setup - name: Lint with black - run: black --diff . + run: black --diff . lint-isort: runs-on: ubuntu-latest From 0798f5815ff7037fae7811e769ff863a336d334f Mon Sep 17 00:00:00 2001 From: ripple Date: Fri, 3 May 2024 15:40:05 +0100 Subject: [PATCH 21/28] removed hacky work around --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e88613a..c4d1634a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: - name: Install dependencies uses: ./.github/actions/setup - name: Lint with pylint - run: find . -type f -name "*.py" | xargs pylint --msg-template='::{category} file={path},line={line},col={column}::{msg}'; if [ $(( $? & 2 )) -eq 2 ] || [ $(( $? & 1 )) -eq 1 ] ; then exit 1; else exit 0; fi + run: pylint --msg-template='::{category} file={path},line={line},col={column}::{msg}' */; if [ $(( $? & 2 )) -eq 2 ] || [ $(( $? & 1 )) -eq 1 ] ; then exit 1; else exit 0; fi lint-black: runs-on: ubuntu-latest From 9d7271a97c40b579bb79540cb9d8ab6fdaeca792 Mon Sep 17 00:00:00 2001 From: ripple Date: Fri, 3 May 2024 15:43:46 +0100 Subject: [PATCH 22/28] added ppylint plugin for formatting logs into a actions understandable format --- .github/requirements-ci.txt | 3 ++- .github/workflows/ci.yml | 2 +- pyproject.toml | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/requirements-ci.txt b/.github/requirements-ci.txt index 08a98c26..6b290f67 100644 --- a/.github/requirements-ci.txt +++ b/.github/requirements-ci.txt @@ -6,4 +6,5 @@ fastjsonschema==2.19.1 pytest==8.2.0 pytest-asyncio==0.23.6 pytest-aiohttp==1.0.5 -autopep8==2.1.0 +autopep8==2.1.0 +pylint-actions==0.5.0 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c4d1634a..9b285f62 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: - name: Install dependencies uses: ./.github/actions/setup - name: Lint with pylint - run: pylint --msg-template='::{category} file={path},line={line},col={column}::{msg}' */; if [ $(( $? & 2 )) -eq 2 ] || [ $(( $? & 1 )) -eq 1 ] ; then exit 1; else exit 0; fi + run: pylint -f actions */; if [ $(( $? & 2 )) -eq 2 ] || [ $(( $? & 1 )) -eq 1 ] ; then exit 1; else exit 0; fi lint-black: runs-on: ubuntu-latest diff --git a/pyproject.toml b/pyproject.toml index 7b2c51b4..15d2819b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,5 +33,8 @@ # Ignore imports when computing similarities. ignore-imports = "yes" +[tool.pylint.main] +load-plugins = "pylint_actions" + [tool.pytest.ini_options] asyncio_mode = "auto" From 3d9145cc598eca9572f8c00c8a6c54515874f611 Mon Sep 17 00:00:00 2001 From: ripple Date: Sun, 5 May 2024 06:51:34 +0100 Subject: [PATCH 23/28] switched to linter's actions --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b285f62..4851d691 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: - name: Install dependencies uses: ./.github/actions/setup - name: Lint with black - run: black --diff . + uses: psf/black@stable lint-isort: runs-on: ubuntu-latest @@ -45,7 +45,7 @@ jobs: - name: Install dependencies uses: ./.github/actions/setup - name: Lint with isort - run: isort --check --diff . + uses: isort/isort-action@master check-json: runs-on: ubuntu-latest From 7a118e2363eb280aefbb2fc426c8614aca62ef9d Mon Sep 17 00:00:00 2001 From: ripple Date: Mon, 13 May 2024 15:07:33 +0100 Subject: [PATCH 24/28] added mypi ci pipeline --- .github/requirements-ci.txt | 1 + .github/workflows/ci.yml | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/.github/requirements-ci.txt b/.github/requirements-ci.txt index 6b290f67..62e0a7a1 100644 --- a/.github/requirements-ci.txt +++ b/.github/requirements-ci.txt @@ -8,3 +8,4 @@ pytest-asyncio==0.23.6 pytest-aiohttp==1.0.5 autopep8==2.1.0 pylint-actions==0.5.0 +mypy==1.10.0 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4851d691..6501ae3c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,6 +47,16 @@ jobs: - name: Lint with isort uses: isort/isort-action@master + lint-mypy: + runs-on: ubuntu-latest + steps: + - name: Checkout the repository at the current branch + uses: actions/checkout@v2 + - name: Install dependencies + uses: ./.github/actions/setup + - name: Lint with mypy + run: mypy --strict . + check-json: runs-on: ubuntu-latest steps: From 9bb205b95eae7d64592141c77710e317cf0d9245 Mon Sep 17 00:00:00 2001 From: ripple Date: Mon, 13 May 2024 15:22:42 +0100 Subject: [PATCH 25/28] switched to ruff --- .github/requirements-ci.txt | 7 +----- .github/workflows/ci.yml | 39 ++------------------------------ .pre-commit-config.yaml | 32 +++++++++++---------------- pyproject.toml | 44 +++++-------------------------------- requirements-dev.txt | 1 + 5 files changed, 23 insertions(+), 100 deletions(-) diff --git a/.github/requirements-ci.txt b/.github/requirements-ci.txt index 62e0a7a1..bccd83f2 100644 --- a/.github/requirements-ci.txt +++ b/.github/requirements-ci.txt @@ -1,11 +1,6 @@ -black==24.4.2 -flake8==7.0.0 -pylint==3.1.0 -isort==5.13.2 fastjsonschema==2.19.1 pytest==8.2.0 pytest-asyncio==0.23.6 pytest-aiohttp==1.0.5 -autopep8==2.1.0 -pylint-actions==0.5.0 mypy==1.10.0 +ruff==0.4.4 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6501ae3c..4a485dcf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,49 +3,14 @@ name: CI on: [pull_request] jobs: - lint-flake8: + ruff: runs-on: ubuntu-latest steps: - name: Checkout the repository at the current branch uses: actions/checkout@v2 - name: Install dependencies uses: ./.github/actions/setup - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings - flake8 . --format="::warning file=%(path)s,line=%(row)d,col=%(col)d::%(text)s" --exit-zero --max-complexity=10 - - lint-pylint: - runs-on: ubuntu-latest - steps: - - name: Checkout the repository at the current branch - uses: actions/checkout@v2 - - name: Install dependencies - uses: ./.github/actions/setup - - name: Lint with pylint - run: pylint -f actions */; if [ $(( $? & 2 )) -eq 2 ] || [ $(( $? & 1 )) -eq 1 ] ; then exit 1; else exit 0; fi - - lint-black: - runs-on: ubuntu-latest - steps: - - name: Checkout the repository at the current branch - uses: actions/checkout@v2 - - name: Install dependencies - uses: ./.github/actions/setup - - name: Lint with black - uses: psf/black@stable - - lint-isort: - runs-on: ubuntu-latest - steps: - - name: Checkout the repository at the current branch - uses: actions/checkout@v2 - - name: Install dependencies - uses: ./.github/actions/setup - - name: Lint with isort - uses: isort/isort-action@master + - uses: chartboost/ruff-action@v1 lint-mypy: runs-on: ubuntu-latest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3309a544..12b6346a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,24 +1,18 @@ fail_fast: true repos: - - repo: local + - repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.4.4 hooks: - - id: pylint - name: pylint - entry: pylint - language: system - types: [python] - args: - [ - "-rn", # Only display messages - "-sn", # Don't display the score - ] - - repo: https://github.com/psf/black - rev: 24.4.2 - hooks: - - id: black - - repo: https://github.com/pycqa/isort - rev: 5.13.2 + # Run the linter. + - id: ruff + args: ["--fix", "--exit-non-zero-on-fix"] + # Run the formatter. + - id: ruff-format + + - repo: https://github.com/pre-commit/mirrors-mypy + rev: 'v1.10.0' # Use the sha / tag you want to point at hooks: - - id: isort - name: isort (python) + - id: mypy + args: [--strict, --ignore-missing-imports] diff --git a/pyproject.toml b/pyproject.toml index 15d2819b..77bef2cf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,40 +1,8 @@ -[tool.black] - line-length = 127 - target-version = ["py38"] - exclude = "env" - -[tool.isort] - multi_line_output = 3 - include_trailing_comma = true - force_grid_wrap = 0 - use_parentheses = true - ensure_newline_before_comments = true - line_length = 127 - skip = "env" - profile = "black" - -[tool.pylint.MASTER] - disable = [ - "C0114", # Missing module docstring - ] - max-attributes = 12 - max-branches = 20 - -[tool.pylint.FORMAT] - max-line-length = 127 - -[tool.pylint.SIMILARITIES] - # Minimum lines number of a similarity. - min-similarity-lines = 10 - # Ignore comments when computing similarities. - ignore-comments = "yes" - # Ignore docstrings when computing similarities. - ignore-docstrings = "yes" - # Ignore imports when computing similarities. - ignore-imports = "yes" - -[tool.pylint.main] -load-plugins = "pylint_actions" - [tool.pytest.ini_options] asyncio_mode = "auto" + +[tool.ruff.lint] +select = ["F", "E", "W", "I", "ASYNC", "PL", "RUF"] + +[tool.ruff] +line-length = 127 diff --git a/requirements-dev.txt b/requirements-dev.txt index bc5e3999..9ee0fae8 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,2 +1,3 @@ pre-commit==3.7.0 pylint==3.1.0 +ruff==0.4.4 From 71a8068f011e65159104f0e9a67c6ca0ff51af02 Mon Sep 17 00:00:00 2001 From: ripple Date: Mon, 13 May 2024 15:46:51 +0100 Subject: [PATCH 26/28] removed fail fast --- .pre-commit-config.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 12b6346a..06631005 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,3 @@ -fail_fast: true - repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. From 6cfa6e45b187224060a7e8f1a7a60650b1840ed8 Mon Sep 17 00:00:00 2001 From: ripple Date: Wed, 24 Jul 2024 14:52:22 +0100 Subject: [PATCH 27/28] added extentions.json and removed pylint --- .vscode/extensions.json | 6 ++---- requirements-dev.txt | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 4acc08f3..7aa3a705 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,9 +1,7 @@ { "recommendations": [ - "ms-python.black-formatter", - "ms-python.isort", - "ms-python.pylint", - "ms-python.python", + "charliermarsh.ruff", + "ms-python.mypy-type-checker", "ms-python.vscode-pylance", ] } diff --git a/requirements-dev.txt b/requirements-dev.txt index 9ee0fae8..a2b616f6 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,2 @@ pre-commit==3.7.0 -pylint==3.1.0 ruff==0.4.4 From d3c483222eda8b35aba6d349a5665f415183eb18 Mon Sep 17 00:00:00 2001 From: ripple Date: Wed, 24 Jul 2024 14:55:28 +0100 Subject: [PATCH 28/28] added mypy --- requirements-dev.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-dev.txt b/requirements-dev.txt index a2b616f6..63255497 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,2 +1,3 @@ pre-commit==3.7.0 ruff==0.4.4 +mypy==1.10.0