Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename_account.py: Fix beancount.core.prices import #172

Merged
merged 1 commit into from
Oct 28, 2022

Conversation

ankurdave
Copy link
Contributor

beancount.ops.prices was renamed to beancount.core.prices in 2016, resulting in the following error:

$ python3 -m beancount_import.rename_account
Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.10/site-packages/beancount_import/rename_account.py", line 11, in <module>
    from beancount.ops import prices
ImportError: cannot import name 'prices' from 'beancount.ops' (/usr/local/lib/python3.10/site-packages/beancount/ops/__init__.py)

After fixing the import, the command runs successfully:

$ python3 -m beancount_import.rename_account
usage: rename_account.py [-h] [-a NEW_ACCOUNT] [-e EVAL] journal query
rename_account.py: error: the following arguments are required: journal, query

`beancount.ops.prices` was [renamed](beancount/beancount@5a818e4) to `beancount.core.prices` in 2016, resulting in the following error:

```
$ python3 -m beancount_import.rename_account
Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.10/site-packages/beancount_import/rename_account.py", line 11, in <module>
    from beancount.ops import prices
ImportError: cannot import name 'prices' from 'beancount.ops' (/usr/local/lib/python3.10/site-packages/beancount/ops/__init__.py)
```

After fixing the import, the command runs successfully:

```
$ python3 -m beancount_import.rename_account
usage: rename_account.py [-h] [-a NEW_ACCOUNT] [-e EVAL] journal query
rename_account.py: error: the following arguments are required: journal, query
```
@Zburatorul
Copy link
Collaborator

Thank you @ankurdave. Can you run tox locally and figure out why the test is failing?

@ankurdave
Copy link
Contributor Author

It appears to be an unrelated failure. Here's the error message:

beancount_import/source/amazon_invoice.py:885: error: Value of type variable "_AddableT1" of "sum" cannot be "Sequence[Adjustment]"

I see a similar failure at the same line on the tox run for master, so I think the build must already have been failing before this PR:

beancount_import/source/amazon_invoice.py:885: error: Value of type variable "_SumT" of "sum" cannot be "Sequence[Adjustment]"

@ankurdave
Copy link
Contributor Author

Indeed, I see the same failure when running tox on master (without this PR):

$ git clone git@github.com:jbms/beancount-import.git
Cloning into 'beancount-import'...
remote: Enumerating objects: 2686, done.
remote: Counting objects: 100% (653/653), done.
remote: Compressing objects: 100% (102/102), done.
remote: Total 2686 (delta 594), reused 551 (delta 551), pack-reused 2033
Receiving objects: 100% (2686/2686), 1.67 MiB | 29.96 MiB/s, done.
Resolving deltas: 100% (1783/1783), done.
$ cd beancount-import
$ tox
[...]
beancount_import/source/amazon_invoice.py:885: error: Value of type variable "_AddableT1" of "sum" cannot be "Sequence[Adjustment]"
Found 1 error in 1 file (checked 60 source files)

@jbms jbms merged commit 24a3da5 into jbms:master Oct 28, 2022
@jbms
Copy link
Owner

jbms commented Oct 28, 2022

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants