Notion Formulas is a Python library designed for composing and manipulating complex formulas for Notion programmatically. Enhance your Notion workspace by leveraging the power of Python to create and manage formulas.
To get started with Notion Formulas, you can install the package using pip:
pip install notion-formulas
from notion_formulas import Number, prop
x: Number = prop("x")
y: Number = prop("y")
print(x + y) # Prints `prop("x") + prop("y")`
The complete Notion Formulas API maintains consistency with the original names, with the following adjustments:
- Camel casing is converted to snake case (e.g.,
replaceAll()
becomesreplace_all()
). - Functions matching python keywords are modified with a trailing underscore: (i.g.
if()
becomesif_()
). - Constants are uppercased (i.g.
e
becomesE
).
The api is fully typed and defines following data types for expressions: Boolean
, Number
, String
, and Date
, allowing your formulas to be typed checked by mypy.
For a comprehensive example, refer to the code that generates a Taskwarrior style urgency score for a Notion task database in examples/urgency.py and the associated output examples/urgency.txt.
Contributions to Notion Formulas are welcome and appreciated. If you'd like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch for your changes.
- Make your changes and update the tests as needed.
- Submit a pull request with your changes.
For major changes, please open an issue first to discuss what you would like to change.
Notion Formulas is released under the MIT license, which allows for free and open use, modification, and distribution.