From 3902d6c210a501bfa3ee5a7a43ee97b90c937399 Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Wed, 26 Jun 2024 10:40:16 -0700 Subject: [PATCH 1/4] Remove flake8 --- .config/constraints.txt | 3 --- .config/pydoclint-baseline.txt | 1 + .config/requirements-lock.txt | 2 -- .config/requirements-test.in | 3 +-- .flake8 | 11 ----------- .pre-commit-config.yaml | 22 +++++++++++----------- .vscode/extensions.json | 2 +- .vscode/settings.json | 5 ++++- .vscode/tasks.json | 31 +++++++++++++++++++++++++++++++ pyproject.toml | 10 ++++++++++ src/ansible_dev_tools/utils.py | 29 ++++++++++++++++++++++++++++- 11 files changed, 87 insertions(+), 32 deletions(-) create mode 100644 .config/pydoclint-baseline.txt delete mode 100644 .flake8 create mode 100644 .vscode/tasks.json diff --git a/.config/constraints.txt b/.config/constraints.txt index 6c98b2cd..e1025205 100644 --- a/.config/constraints.txt +++ b/.config/constraints.txt @@ -51,7 +51,6 @@ enrich==1.2.7 exceptiongroup==1.2.1 execnet==2.1.1 filelock==3.15.4 -flake8==7.1.0 ghp-import==2.1.0 griffe==0.47.0 gunicorn==22.0.0 @@ -115,10 +114,8 @@ platformdirs==4.2.2 pluggy==1.5.0 pre-commit==3.7.1 ptyprocess==0.7.0 -pycodestyle==2.12.0 pycparser==2.22 pydoclint==0.5.1 -pyflakes==3.2.0 pygments==2.18.0 pylint==3.2.4 pymdown-extensions==10.8.1 diff --git a/.config/pydoclint-baseline.txt b/.config/pydoclint-baseline.txt new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/.config/pydoclint-baseline.txt @@ -0,0 +1 @@ + diff --git a/.config/requirements-lock.txt b/.config/requirements-lock.txt index c8d87a65..8365e02c 100644 --- a/.config/requirements-lock.txt +++ b/.config/requirements-lock.txt @@ -77,7 +77,6 @@ python-gnupg==0.5.2 pyyaml==6.0.1 referencing==0.31.1 requests==2.32.3 -requirements-parser==0.9.0 resolvelib==1.0.1 rfc3339-validator==0.1.4 rich==13.7.1 @@ -90,7 +89,6 @@ subprocess-tee==0.4.2 tomli==2.0.1 tox==4.15.1 tox-ansible==24.6.18 -types-setuptools==70.1.0.20240625 typing-extensions==4.12.2 tzdata==2024.1 urllib3==2.2.2 diff --git a/.config/requirements-test.in b/.config/requirements-test.in index b0259b15..85135b16 100644 --- a/.config/requirements-test.in +++ b/.config/requirements-test.in @@ -1,11 +1,10 @@ ansible-dev-tools[server] black coverage[toml] -flake8 mypy pip-tools pre-commit -pydoclint[flake8] +pydoclint pylint pytest pytest-xdist diff --git a/.flake8 b/.flake8 deleted file mode 100644 index f9f5627f..00000000 --- a/.flake8 +++ /dev/null @@ -1,11 +0,0 @@ -[flake8] -allow-init-docstring = True -arg-type-hints-in-docstring = False -check-return-types = False -select = DOC -show-filenames-in-every-violation-message = True -skip-checking-short-docstrings = False -filename = - */src/**/*.py - */tests/**/*.py -style = google diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b38a6f5f..fad5477b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,7 +30,7 @@ repos: - id: remove-tabs - repo: https://github.com/pycontribs/mirrors-prettier - rev: v3.3.0 + rev: v3.3.2 hooks: - id: prettier always_run: true @@ -55,28 +55,28 @@ repos: - id: tox-ini-fmt - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.7 + rev: v0.4.10 hooks: - id: ruff args: - --exit-non-zero-on-fix - repo: https://github.com/streetsidesoftware/cspell-cli - rev: v8.8.2 + rev: v8.9.0 hooks: - id: cspell name: Spell check with cspell - - repo: https://github.com/pycqa/flake8 - rev: 7.0.0 + - repo: https://github.com/jsh9/pydoclint + rev: 7.1.0 hooks: - - id: flake8 - name: flake8(pydoclint) - additional_dependencies: - - pydoclint[flake8] + - id: pydoclint + # This allows automatic reduction of the baseline file when needed. + entry: sh -ec "pydoclint . && pydoclint --generate-baseline=1 ." + pass_filenames: false - repo: https://github.com/pycqa/pylint.git - rev: v3.2.2 + rev: v3.2.4 hooks: - id: pylint args: @@ -90,7 +90,7 @@ repos: - pyyaml - repo: https://github.com/pre-commit/mirrors-mypy.git - rev: v1.10.0 + rev: v1.10.1 hooks: - id: mypy additional_dependencies: diff --git a/.vscode/extensions.json b/.vscode/extensions.json index cee12411..81213be4 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -2,10 +2,10 @@ "recommendations": [ "charliermarsh.ruff", "esbenp.prettier-vscode", + "gruntfuggly.triggertaskonsave", "markis.code-coverage", "ms-python.black-formatter", "ms-python.debugpy", - "ms-python.flake8", "ms-python.mypy-type-checker", "ms-python.pylint", "ms-python.python", diff --git a/.vscode/settings.json b/.vscode/settings.json index d80345ac..c9a2baa3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -18,5 +18,8 @@ "pylint.importStrategy": "fromEnvironment", "python.testing.pytestArgs": ["tests"], "python.testing.pytestEnabled": true, - "python.testing.unittestEnabled": false + "python.testing.unittestEnabled": false, + "triggerTaskOnSave.tasks": { + "pydoclint": ["*.py"] + } } diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..494f1747 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,31 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "pydoclint", + "type": "shell", + "command": "pydoclint", + "args": ["."], + "presentation": { + "reveal": "never" + }, + "problemMatcher": { + "owner": "pydoclint", + "fileLocation": ["relative", "${workspaceFolder}"], + "pattern": { + "regexp": "^(.*?):(\\d+):\\s(.*?):\\s(.*)$", + "file": 1, + "line": 2, + "code": 3, + "message": 4 + } + }, + "group": { + "kind": "none", + "isDefault": true + } + } + ] +} diff --git a/pyproject.toml b/pyproject.toml index 0218dd1d..1caa6d01 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,6 +67,16 @@ strict = true ignore_missing_imports = true module = ["gunicorn.*", "openapi_core.*"] +[tool.pydoclint] +allow-init-docstring = true +arg-type-hints-in-docstring = false +baseline = ".config/pydoclint-baseline.txt" +check-return-types = false +exclude = '\.git|\.tox|build|out|venv' +show-filenames-in-every-violation-message = true +skip-checking-short-docstrings = false +style = "google" + [tool.pylint] [tool.pylint.format] diff --git a/src/ansible_dev_tools/utils.py b/src/ansible_dev_tools/utils.py index 425731f1..c18cb488 100644 --- a/src/ansible_dev_tools/utils.py +++ b/src/ansible_dev_tools/utils.py @@ -2,7 +2,34 @@ class Colors: - """ANSI color codes.""" + """ANSI color codes. + + Attributes: + BLACK: Black color. + RED: Red color. + GREEN: Green color. + BROWN: Brown color. + BLUE: Blue color. + PURPLE: Purple color. + CYAN: Cyan color. + LIGHT_GRAY: Light gray color. + DARK_GRAY: Dark gray color. + LIGHT_RED: Light red color. + LIGHT_GREEN: Light green color. + YELLOW: Yellow color. + LIGHT_BLUE: Light blue color. + LIGHT_PURPLE: Light purple color. + LIGHT_CYAN: Light cyan color. + LIGHT_WHITE: Light white color. + BOLD: Bold text. + FAINT: Faint text. + ITALIC: Italic text. + UNDERLINE: Underline text. + BLINK: Blink text. + NEGATIVE: Negative text. + CROSSED: Crossed text. + END: Reset color. + """ BLACK = "\033[0;30m" RED = "\033[0;31m" From a2e46ee915e867b1232cd725d9ab8dadb64acf2c Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Wed, 26 Jun 2024 10:56:03 -0700 Subject: [PATCH 2/4] Correct version --- .pre-commit-config.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fad5477b..7aec2374 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,6 +28,7 @@ repos: rev: v1.5.5 hooks: - id: remove-tabs + exclude: .config/pydoclint-baseline.txt - repo: https://github.com/pycontribs/mirrors-prettier rev: v3.3.2 @@ -68,7 +69,7 @@ repos: name: Spell check with cspell - repo: https://github.com/jsh9/pydoclint - rev: 7.1.0 + rev: 0.5.1 hooks: - id: pydoclint # This allows automatic reduction of the baseline file when needed. From 415b35f0af377ab2d6a4a69ca83885e6af0eaac4 Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Wed, 26 Jun 2024 10:57:49 -0700 Subject: [PATCH 3/4] Correct exclude --- .pre-commit-config.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7aec2374..605190d4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,7 +28,10 @@ repos: rev: v1.5.5 hooks: - id: remove-tabs - exclude: .config/pydoclint-baseline.txt + exclude: > + (?x)^( + .config/pydoclint-baseline.txt + )$ - repo: https://github.com/pycontribs/mirrors-prettier rev: v3.3.2 From 875e09ea3678f7d58ab6cc967d5f6ff946538653 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 26 Jun 2024 18:00:36 +0000 Subject: [PATCH 4/4] chore: auto fixes from pre-commit.com hooks --- .config/pydoclint-baseline.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/.config/pydoclint-baseline.txt b/.config/pydoclint-baseline.txt index 8b137891..e69de29b 100644 --- a/.config/pydoclint-baseline.txt +++ b/.config/pydoclint-baseline.txt @@ -1 +0,0 @@ -