Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Opinionated Beancount formatter library, just like Python's black code formatter but for Beancount
Try it out online here
bean-example
can be formatted in around 1 second*
will be formatted in groups without changing the overall structureThe original project beancount-black was meant to be an internal tool built by Launch Platform LLC for
A modern accounting book service based on the most popular open source version control system Git and text-based double entry accounting book software Beancount. We realized adding new entries with BeanHub automatically over time makes the beancount file a mess. So, a strong code formatter is needed. While SaaS businesses won't be required to open-source an internal tool like this, we still love that the service is only possible because of the open-source tool we are using. It would be greatly beneficial for the community to access a tool like this, so we've decided to open-source it under an MIT license. We hope you find this tool useful 😄
[!WARNING]
Bean-black command-line is deprecated and will remain as is, with no feature updates. It's subject to removal in future versions. In the future, thebeancount-black
package will focus on serving as a Beancount formatter library. Please use beanhub-cli instead if you need a formatter command-line tool. Newer features like file traversal, account, or commodity renaming will only be available withbeanhub-cli
.
To install the formatter, simply run
pip install beancount-black
Run
bean-black /path/to/file.bean
Then the file will be formatted.
Since this tool is still in its early stage, a backup file at <filepath>.backup
will be created automatically by default just in case.
The creation of backup files can be disabled by passing -n
or --no-backup
like this
bean-black -n /path/to/file.bean
It's highly recommended to use BeanHub, Git or other version control system to track your Beancount book files before running the formatter against them without a backup.
If you want to run the formatter programmatically, you can do this
import io
from beancount_parser.parser import make_parser
from beancount_black.formatter import Formatter
parser = make_parser()
formatter = Formatter()
tree = parser.parse(beancount_content)
output_file = io.StringIO()
formatter.format(tree, output_file)
You can run the formatter in STDIN mode by passing -s
or --stdin-mode
argument like this:
bean-black -s
Sometimes you might encounter problems when formatting some beancount files.
To debug and better understand which line is causing the problem, you can change the log level by passing -l
argument with debug
or verbose
.
For example:
bean-black -n /path/to/file.bean -l verbose
With verbose
, details of the parsed object will be printed.
With debug
, only the line number and type of entry will be printed.
You can also use LOG_LEVEL
environment variable as well.
The available log level options are:
include
statements and also format those filesFeedbacks, bugs reporting or feature requests are welcome 🙌, just please open an issue. No guarantee we have time to deal with them, but will see what we can do.
FAQs
Opinioned beancount formatter library
We found that beancount-black demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.