From 5f11caab670cd9640b69ba64e337128bea3f43c6 Mon Sep 17 00:00:00 2001 From: Ming Di Leom <2809763-curben@users.noreply.gitlab.com> Date: Mon, 6 Mar 2023 10:46:34 +0000 Subject: [PATCH] chore: ruff linter - replace pylint & isort --- .gitignore | 1 + .pre-commit-config.yaml | 21 ++++----------------- .vscode/settings.json | 6 +----- bin/utils.py | 3 ++- pyproject.toml | 8 +++++--- requirements-dev.txt | 2 +- 6 files changed, 14 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index 6a37edb..874f5fa 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ pip-log.txt pip-delete-this-directory.txt lib/ malware_filter-*.tar.gz +.ruff_cache/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4ce3703..13ee95a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,28 +17,15 @@ repos: hooks: - id: end-of-file-fixer - id: trailing-whitespace - - repo: https://github.com/PyCQA/isort - rev: "5.11.4" + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: "v0.0.254" hooks: - - id: isort - types: [python] - args: [ - ".", # sort all Python files recursively - ] + - id: ruff + args: [--fix, --exit-non-zero-on-fix] - repo: https://github.com/psf/black rev: 22.12.0 hooks: - id: black - - repo: https://github.com/PyCQA/pylint - rev: "v2.15.10" - hooks: - - id: pylint - language: system - types: [python] - args: [ - "-rn", # Only display messages - "-sn", # Don't display the score - ] - repo: https://github.com/pre-commit/mirrors-prettier rev: "v2.7.1" hooks: diff --git a/.vscode/settings.json b/.vscode/settings.json index 17cfeb2..dab17f2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,14 +9,10 @@ "editor.formatOnSave": true, "editor.tabSize": 4, "editor.codeActionsOnSave": { + "source.fixAll": true, "source.organizeImports": true } }, - "isort.args": ["--profile", "black"], - "[javascript]": { - "editor.formatOnSave": true, - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, "[markdown]": { "editor.formatOnSave": true, "editor.defaultFormatter": "esbenp.prettier-vscode" diff --git a/bin/utils.py b/bin/utils.py index f5cc00e..04886a0 100644 --- a/bin/utils.py +++ b/bin/utils.py @@ -105,7 +105,8 @@ class Utility: Arguments: row {dict} -- A row of an array-parsed CSV - prefix_opt {string/list} -- A column name or a comma-separated list of column names to have wildcard prefixed to their non-empty value. + prefix_opt {string/list} -- A column name or a comma-separated list of column names to have + wildcard prefixed to their non-empty value. suffix_opt {string/list} -- Same as prefix_opt but have the wildcard suffixed instead. affix_opt {string/list} -- Same as prefix_opt but have the wildcard prefixed and suffixed. diff --git a/pyproject.toml b/pyproject.toml index 6b056f1..88bd104 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,3 @@ -[tool.isort] -profile = "black" - [tool.pylint.'MASTER'] py-version = "3.10" init-hook='import sys; sys.path.append("./bin")' @@ -30,3 +27,8 @@ disable = [ indent-after-paren = 4 indent-string = " " expected-line-ending-format="LF" + +[tool.ruff] +line-length = 115 +# Module level import not at top of file (`E402`). +ignore = ["E402"] diff --git a/requirements-dev.txt b/requirements-dev.txt index 8b5b30d..f822796 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,5 @@ -r requirements.txt pylint == 2.* -isort == 5.* pre-commit == 2.* black ~= 22.1 +ruff == 0.0.*