diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 91ad31e8..c1585c50 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -46,6 +46,6 @@ jobs: - uses: actions/setup-python@v5 with: python-version: '3.11' - - run: pip install -r requirements.txt wheel build - - run: python -m build --no-isolation + - run: pip install build + - run: python -m build - run: python -m pip install dist/beanquery-*.whl diff --git a/beanquery/query_render.py b/beanquery/query_render.py index ebcfbcae..24d53618 100644 --- a/beanquery/query_render.py +++ b/beanquery/query_render.py @@ -22,6 +22,23 @@ class Align(enum.Enum): RIGHT = 1 +class _CurrencyContext(display_context._CurrencyContext): + def __init__(self): + super().__init__() + # Since commit 10b6f5efd2385e3d0efe6715584d7f540e2e7abf + # beancount assumes the presence of a sign unconditionally , + # changing the formatting of columns that do not contain + # negative numbers. Revert the change. + self.has_sign = False + + +class _DisplayContext(display_context.DisplayContext): + def __init__(self): + self.ccontexts = collections.defaultdict(_CurrencyContext) + self.ccontexts["__default__"] = _CurrencyContext() + self.commas = False + + class RenderContext: """Hold the query rendering configuration.""" @@ -235,7 +252,7 @@ def __init__(self, ctx): # determine the quantization of the column values. self.quantize = ctx.dcontext.quantize # Use column specific display context for formatting. - self.dcontext = display_context.DisplayContext() + self.dcontext = _DisplayContext() # Maximum width of the commodity symbol. self.curwidth = 0 diff --git a/pyproject.toml b/pyproject.toml index 0e08d27c..2778f7ee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,13 @@ [build-system] -requires = ['setuptools'] +requires = ['setuptools >= 77.0.3'] build-backend = 'setuptools.build_meta' [project] name = 'beanquery' version = '0.3.0.dev0' description = 'Customizable lightweight SQL query tool' -license = { file = 'LICENSE' } +license = 'GPL-2.0-only' +license-files = ['LICENSE'] readme = 'README.rst' authors = [ { name = 'Martin Blais', email = 'blais@furius.ca' }, @@ -19,7 +20,6 @@ keywords = [ 'accounting', 'ledger', 'beancount', 'SQL', 'BQL' ] classifiers = [ - 'License :: OSI Approved :: GNU General Public License v2 (GPLv2)', 'Programming Language :: Python :: 3 :: Only', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', @@ -67,6 +67,7 @@ line-length = 128 target-version = 'py38' [tool.ruff.lint] +pyupgrade.keep-runtime-typing = true select = ['E', 'F', 'W', 'UP', 'B', 'C4', 'PL', 'RUF'] ignore = [ 'B007', @@ -79,6 +80,7 @@ ignore = [ 'PLR0915', 'PLR1714', 'PLR2004', + 'PLW1641', # eq-without-hash 'PLW2901', 'RUF012', 'RUF023', # unsorted-dunder-slots diff --git a/requirements.txt b/requirements.txt index 3104dcef..f18e1555 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ beancount >=2.3.4 click >7.0 python-dateutil >=2.6.0 -tatsu >=5.7.4, <5.8.0 +tatsu-lts