Skip to content

Commit

Permalink
chore: upgrade to beancount v3 and beanquery
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Ryall authored and polarmutex committed Jan 12, 2025
1 parent 75b07e7 commit f61eb91
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 7 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
watch_file uv.lock
use flake
17 changes: 14 additions & 3 deletions example.beancount
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,20 @@
option "title" "Huge Example file"
option "operating_currency" "USD"

2010-01-01 custom "fava-extension" "fava_envelope" "{}"
2010-01-01 custom "envelope" "start date" "2015-01"
2010-01-01 custom "envelope" "budget account" "Assets:US:BofA:Checking"
2010-01-01 custom "fava-extension" "fava_envelope" "{
'budgets': [
{
'name': 'USD',
'currency': 'USD',
'start date': '2015-01',
'budget accounts': [
'Assets:US:BofA:Checking'
],
'mapping': []
},
],
}"

2015-01-01 custom "envelope" "allocate" "Expenses:Health:Dental:Insurance" 5.80
2017-06-01 custom "envelope" "allocate" "Expenses:Financial:Fees" 0

Expand Down
3 changes: 3 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@
unset PYTHONPATH
export REPO_ROOT=$(git rev-parse --show-toplevel)
${config.pre-commit.installationScript}
# set a venv folder for basedpyright
venv="$(cd $(dirname $(which python)); cd ..; pwd)"
ln -Tsf "$venv" .venv
'';
};
packages = {
Expand Down
15 changes: 14 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ classifiers = [
dependencies = [
"fava>=1.26",
"pandas>=2.2.2",
"Click >= 7"
"Click >= 7",
"beanquery>=0.1.0",
"beancount>=3.0.0",
]

[dependency-groups]
Expand Down Expand Up @@ -57,6 +59,15 @@ changelog = "https://github.com/polarmutex/fava-envelope/master/CHANGELOG.md"
[tool.black]
line-length = 79

[tool.ruff.lint]
select = [
# "C90", # McCabe cyclomatic complexity
# "E", # pycodestyle
# "N", # pep8-naming
# "U", # pyupgrade
# "W", # pycodestyle
]

[tool.basedpyright]
# many settings are not enabled even in strict mode, which is why basedpyright includes an "all" option
# you can then decide which rules you want to disable
Expand All @@ -66,3 +77,5 @@ exclude = [
".direnv",
]
useLibraryCodeForTypes = true
venvPath="."
venv=".venv"
6 changes: 3 additions & 3 deletions src/fava_envelope/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from beancount.core import data
from beancount.core import inventory
from beancount.parser import options
from beancount.query import query
from beanquery import query
from fava.ext import FavaExtensionBase
from fava.helpers import FavaAPIError

Expand Down Expand Up @@ -99,8 +99,8 @@ def after_load_file(self) -> None:
print(f"processiing budget {budget}")
bc = self.process_budget(budget)
self.budgets.append(bc)
print(self.budgets[0].top)
print(self.budgets[0].envelopes)
# print(self.budgets[0].top)
# print(self.budgets[0].envelopes)

def process_budget(self, cfg: BudgetConfig) -> BudgetCtx:
months = []
Expand Down
4 changes: 4 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f61eb91

Please sign in to comment.