From a446a187cc7b0c99f92f0942d2f4fc233e775645 Mon Sep 17 00:00:00 2001 From: Jakob Schnitzer Date: Mon, 20 Jan 2025 20:33:43 +0100 Subject: [PATCH] modernise --- .github/workflows/ci.yml | 10 +++++----- .pre-commit-config.yaml | 23 ++++++----------------- Makefile | 9 ++++++--- README.md | 2 +- fava_plugins/split_income.py | 1 + fava_plugins/todo_as_error.py | 1 + pyproject.toml | 4 ++++ setup.cfg | 10 ++++------ tox.ini | 12 +----------- 9 files changed, 29 insertions(+), 43 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5e98798..278fb8b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,17 +7,17 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10"] + python-version: ["3.9", "3.13"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install Dependencies - run: pip install tox wheel setuptools + run: pip install tox wheel setuptools pre-commit - name: Run lint - run: tox -e lint + run: pre-commit run -a - name: Run tests run: tox -e py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 321aaa3..10a87f7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,18 +1,7 @@ repos: - - repo: https://github.com/psf/black - rev: 22.8.0 - hooks: - - id: black - - repo: https://github.com/asottile/reorder_python_imports - rev: v3.8.3 - hooks: - - id: reorder-python-imports - - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 - hooks: - - id: flake8 - - repo: https://github.com/asottile/pyupgrade - rev: v2.38.2 - hooks: - - id: pyupgrade - args: ["--py36-plus"] + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.9.2 + hooks: + - id: ruff + args: ["--fix"] + - id: ruff-format diff --git a/Makefile b/Makefile index ae15769..0d51469 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,9 @@ +test: + tox -e py + +lint: + pre-commit run -a + upload: python setup.py sdist bdist_wheel twine upload dist/* - -test: - tox diff --git a/README.md b/README.md index e0ab089..2eba3b4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # fava-plugins -a collection of Beancount plugins. Install with `pip3 install fava-plugins`. +a collection of Beancount plugins. Install with `pip install fava-plugins`. - [`split_income`](https://github.com/beancount/fava-plugins/blob/main/fava_plugins/split_income.py): Split income transactions into pre-tax and post-tax postings. - [`todo_as_error`](https://github.com/beancount/fava-plugins/blob/main/fava_plugins/todo_as_error.py): Display 'todo'-metadata-entries as errors. diff --git a/fava_plugins/split_income.py b/fava_plugins/split_income.py index d215367..b4338f3 100644 --- a/fava_plugins/split_income.py +++ b/fava_plugins/split_income.py @@ -49,6 +49,7 @@ Income:Net 800.00 EUR Income:Net:Bonus 100.00 EUR """ + import ast import collections import copy diff --git a/fava_plugins/todo_as_error.py b/fava_plugins/todo_as_error.py index 12419c0..4653192 100644 --- a/fava_plugins/todo_as_error.py +++ b/fava_plugins/todo_as_error.py @@ -11,6 +11,7 @@ Expenses:Groceries 150.00 USD Assets:Cash """ + import collections from beancount.core.data import Transaction diff --git a/pyproject.toml b/pyproject.toml index 07aaaec..309d7b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,6 +5,10 @@ build-backend = "setuptools.build_meta" [tool.black] line-length = 79 +[tool.ruff] +target-version = "py39" +line-length = 79 + [tool.pylint.'MESSAGES CONTROL'] disable = [ "too-few-public-methods", diff --git a/setup.cfg b/setup.cfg index 4396ff5..ba81965 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,19 +16,17 @@ classifiers = Intended Audience :: Information Technology License :: OSI Approved :: MIT License Natural Language :: English - Programming Language :: JavaScript - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3 :: Only Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3 :: Only - Topic :: Internet :: WWW/HTTP :: Dynamic Content + Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 + Programming Language :: Python :: 3.13 Topic :: Office/Business :: Financial :: Accounting Topic :: Office/Business :: Financial :: Investment [options] packages = find: -zip_safe = False install_requires = beancount>=2.0 include_package_data = True diff --git a/tox.ini b/tox.ini index 6b69a0d..644223b 100644 --- a/tox.ini +++ b/tox.ini @@ -1,18 +1,8 @@ [tox] -envlist = lint,py +envlist = py isolated_build = True [testenv] deps = pytest commands = pytest tests - -[testenv:lint] -deps = - flake8 - pylint - pytest -commands = - flake8 fava_plugins tests - pylint fava_plugins - pylint tests -d missing-docstring -d not-callable