From 70aa526e49c6dc1a45e06c065d51bfa668bb9609 Mon Sep 17 00:00:00 2001 From: Dennis Hannusch Date: Wed, 7 Jun 2023 06:41:52 -0500 Subject: [PATCH] Add ruff to project for linting --- .github/workflows/pylint.yml | 23 -------------- .github/workflows/ruff.yml | 10 ++++++ .gitignore | 3 +- Pipfile | 1 + Pipfile.lock | 31 +++++++++++++++--- auto-newsletter/newsletter_writer.py | 3 +- pyproject.toml | 47 ++++++++++++++++++++++++++++ 7 files changed, 88 insertions(+), 30 deletions(-) delete mode 100644 .github/workflows/pylint.yml create mode 100644 .github/workflows/ruff.yml create mode 100644 pyproject.toml diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml deleted file mode 100644 index 383e65c..0000000 --- a/.github/workflows/pylint.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Pylint - -on: [push] - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.8", "3.9", "3.10"] - steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pylint - - name: Analysing the code with pylint - run: | - pylint $(git ls-files '*.py') diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml new file mode 100644 index 0000000..f616987 --- /dev/null +++ b/.github/workflows/ruff.yml @@ -0,0 +1,10 @@ +name: Ruff + +on: [push, pull_request] + +jobs: + ruff: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: chartboost/ruff-action@v1 diff --git a/.gitignore b/.gitignore index 530aa81..57a767c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ debug newsletters .vscode -.auto-newsletter \ No newline at end of file +.auto-newsletter +.ruff_cache \ No newline at end of file diff --git a/Pipfile b/Pipfile index 5d990a4..1724bb6 100644 --- a/Pipfile +++ b/Pipfile @@ -17,6 +17,7 @@ trafilatura = "*" urllib3 = "==1.26.6" torch = {version = "==1.13.1", index = "downloadpytorch"} simple-term-menu = "*" +ruff = "*" [dev-packages] diff --git a/Pipfile.lock b/Pipfile.lock index 1224d9d..f7952c3 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "437ee9b4f8d64ebded0d313836ab3816002e0a01bf96bc881fa08bc01e2f81b8" + "sha256": "34ba982ce9e4b8f82dea6096a46789e543f137c60786726d36e1822e635598d0" }, "pipfile-spec": 6, "requires": { @@ -748,11 +748,11 @@ }, "openai": { "hashes": [ - "sha256:788fb7fa85bf7caac6c1ed7eea5984254a1bdaf09ef485acf0e5718c8b2dc25a", - "sha256:bca95fd4c3054ef38924def096396122130454442ec52005915ecf8269626b1d" + "sha256:2483095c7db1eee274cebac79e315a986c4e55207bb4fa7b82d185b3a2ed9536", + "sha256:e0a7c2f7da26bdbe5354b03c6d4b82a2f34bd4458c7a17ae1a7092c3e397e03c" ], "markers": "python_full_version >= '3.7.1'", - "version": "==0.27.7" + "version": "==0.27.8" }, "packaging": { "hashes": [ @@ -965,6 +965,29 @@ "index": "pypi", "version": "==2.31.0" }, + "ruff": { + "hashes": [ + "sha256:140e912a18a662062b04b489861e5aebdbe1a1668bf416e5a951f2347aa65907", + "sha256:191cdddfc82165afd63ab29ad671419a90a5e699b026ac2d9c61232543965de6", + "sha256:1a627978df924635f7d1a169a98abb2ea488c2d409da56a3f9e44a82d30606ac", + "sha256:403e8f9de18b2279d65015a45e0e0d98d60ad878d52f46904f502a4d09465815", + "sha256:45b3c3551a798d9786779c6dd7ad2224af6e06162e17f4a0e7678d3e9115ae56", + "sha256:5a73ffda5548ea8e28e0afcfa698a8675bb17f7048299327f4c1a1287b6e36a2", + "sha256:67525aa821ff0f8371eaa28c73dc467b8eea18931a8bd749775ad538fe1f35e6", + "sha256:7543b8a32e000ed30727ca6e570a90ab26f8899ee23dffb28806dfc2618782fb", + "sha256:7e34ca86329a542ab5d31f4fc2702f556d62748f4217e2f6951aef93176190f0", + "sha256:9e5de841e09ea75a26956a2cda930d1260c9d8d94cbe57c13b3e881d96526860", + "sha256:be4590137a31c47e7f6ef4488d60102c68102f842453355d8073193a30199aa7", + "sha256:cd43c1aff3eefb2193a125a12124438f65a8d1a6da0e86f8545141d48f6a39fa", + "sha256:efdfe7fea656eb2ed54f123135c04f71744ad6e4c0c6be156d46e7a2f4730d48", + "sha256:f3fd9e7c7afb7740d2734af3348e6c88226b42acba2e10a3d1e449caa67e4652", + "sha256:f445c56cdc8c12fc28a0b16588ba33abebb6340cb5b1b5a7d5668d4c0b31ad33", + "sha256:f47d8a192f6869e95896dc5bb7e825a4f9c554136b9c3bddd38389e43d4db08b", + "sha256:fca503741f4b23a7179fd7a9bc50fc2cca637e9a4da027776f38690c50ae559f" + ], + "index": "pypi", + "version": "==0.0.271" + }, "simple-term-menu": { "hashes": [ "sha256:368b4158d1749b868552fb6c054b8301785086c71a7253dac8404cc3cb2d30e8", diff --git a/auto-newsletter/newsletter_writer.py b/auto-newsletter/newsletter_writer.py index 3fffb08..ea9f482 100644 --- a/auto-newsletter/newsletter_writer.py +++ b/auto-newsletter/newsletter_writer.py @@ -1,8 +1,7 @@ from datetime import datetime from content import Content import guidance -from debug import debug, debug_guidance -from loadingbar import LoadingBar +from debug import debug_guidance from spinner import Spinner import json from colorama import Fore, Style diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..effa307 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,47 @@ +[tool.ruff] +# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default. +select = ["E", "F"] +ignore = ["E501"] + +# Allow autofix for all enabled rules (when `--fix`) is provided. +fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"] +unfixable = [] + +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".mypy_cache", + ".nox", + ".pants.d", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "venv", +] +per-file-ignores = {} + +# Same as Black. +line-length = 88 + +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +# Assume Python 3.10. +target-version = "py310" + +[tool.ruff.mccabe] +# Unlike Flake8, default to a complexity level of 10. +max-complexity = 10