Skip to main content

bobbie

Version PyPI Latest Release GitHub Latest Release
Status Build Status Code Coverage Development Status Project Stability
Documentation Hosted By
Tools Documentation Linter Type Checker Dependency Manager Pre-commit CI Editor Settings Repository Template Dependency Maintainer
Compatibility Compatible Python Versions Linux MacOS Windows
Stats PyPI Download Rate (per month) GitHub Stars GitHub Contributors GitHub Issues GitHub Forks

What is bobbie?

It's better to know what you want and who you are

Named after Roberta Draper ("Bobbie") from "The Expanse," bobbie provides a lightweight and easy-to-use way to store and access configuration settings for a Python project.

Why use bobbie?

It's better to know what you want and who you are

There are numerous options for storing configuration settings in Python. So, what makes bobbie different?

  • Flexible: a Settings instance is easily built from a dict, Python module, or file (ini, json, toml, and yaml formats are supported).
  • Lightweight: an efficient codebase ensures a very small memory footprint.
  • Intuitive: a create class method constructs Settings (from any data source).
  • Portable: Settings can be exported to any of the supported file types, so settings built in code can be saved as a settings file.
  • Convenient: unlike configparser, values stored as strings (such as in ini files) are automatically converted to the matching Python types when Settings is created.

The comparison table below shows how bobbie compares to the other major options that store configuration options for Python projects.

Getting started

It's better to know what you want and who you are

Installation

To install bobbie, use pip:

pip install bobbie

Loading and exporting yaml files requires the yaml extra, which adds PyYAML. Exporting toml files requires the toml extra, which adds tomli-w:

pip install "bobbie[toml,yaml]"

Create a Settings instance

bobbie supports several ways to create a Settings instance. You can either:

  • If the settings are in a file, call a class method specific to the file type (from_yaml in the second example below);
  • Call a class method for the general type of source data (from_dict or from_file);
  • Call the create class method and it will automatically figure out the appropriate constructor; or
  • If the settings data is in a dict-like object, pass it as the first argument to Settings.

From a dict

import bobbie

configuration = {
  'general': {
    'verbose': False,
    'seed': 43,
    'parallelize': False},
  'files': {
    'source_format': 'csv',
    'file_encoding': 'windows-1252',
    'float_format': '%.4f',
    'export_results': True}}
# You can pick a specific constructor method.
settings = bobbie.Settings.from_dict(configuration)
# Or, may use the general `create` method.
settings = bobbie.Settings.create(configuration)
# Or, just send a `dict` to `Settings` itself.
settings = bobbie.Settings(configuration)

From a file

import bobbie

# You may use the general `create` method.
settings = bobbie.Settings.create('settings_file.yaml')
# Or, the `from_file` method.
settings = bobbie.Settings.from_file('settings_file.yaml')
# Or, the `from_yaml` method. They all do the same thing.
settings = bobbie.Settings.from_yaml('settings_file.yaml')

If the file is a Python module, it must contain a variable named settings in the module namespace (unless you change the global setting for the variable name).

Type inference

ini and json files often store numbers, booleans, and lists as strings, so bobbie converts their values to the matching Python types:

  • '42' becomes 42 and '2.5' becomes 2.5.
  • 'true', 'yes', 'false', and 'no' (in any case) become True or False.
  • '[x, y, z]' and 'x, y, z' become ['x', 'y', 'z']. A comma followed by a line break also splits a list, so a list can span several lines of an ini file, but a comma with nothing after it, as in 'x,y', does not split a string.
  • '{a: 1, b: [x, y]}' becomes {'a': 1, 'b': ['x', 'y']}.

Items in lists and dicts are converted the same way and may be nested. Put an item in quotes (such as ["a, b", '1']) to keep it as a string.

toml, yaml, and Python module values are not converted because those formats already store their own types. So, a toml value of "[a, b]" stays a string. See the Advanced User Guide for the exact rules and how to turn inference on or off for each file type.

Export settings to a file

bobbie can also create a settings file from a Settings instance. You can either:

  • Call the method specific to the file type (to_ini, to_json, to_module, to_toml, or to_yaml); or
  • Call the to_file method and it will pick the appropriate method from the file extension.
import bobbie

settings = bobbie.Settings.create('settings_file.yaml')
settings.add('general', {'seed': 7})
# You may use the general `to_file` method.
settings.to_file('settings_file.toml')
# Or, the `to_toml` method. They both do the same thing.
settings.to_toml('settings_file.toml')

Any additional keyword arguments are passed to the writer for the file type (such as indent for json.dump). An existing file is overwritten.

Exported files can be loaded back into the same Settings. For ini files, lists and dicts are written in the form that type inference reads (such as [x, y, z]), and items that would otherwise be converted are quoted. Because ini files store everything as strings, every top-level value must be a section (a dict), and a string that looks like another type (such as '42') is loaded as that type. A Settings exported with to_module stores its values in a module-level variable named settings. See the Advanced User Guide for the arguments each exporter accepts and the other ini limits.

Contributing

This could be a really big deal

Contributors are always welcome. Feel free to grab an issue to work on or make a suggested improvement. If you wish to contribute, please read the Contribution Guide and Code of Conduct.

Similar projects

There are a lot of great packages for storing project settings. The table below shows the features of the leading libraries.

Feature Comparison of Python Configuration Libraries

Library Typing Secrets Export dict ini json py toml yaml
bobbie ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
configparser ✅ ✅
dynaconf ✅ ✅ ✅ ✅ ✅ ✅ ✅
Parser-it ✅ ✅ ✅ ✅ ✅
python-decouple ✅ ✅ ✅
pyconfig ✅
pydantic-settings ✅ ✅

Bobbie Draper destroys a robotic arm in an arm-wrestling match

As you can see, bobbie lacks a method for storing passwords, encryption keys, and other secrets. That is because it is focused on internal Python projects and the goal of keeping its resource usage as low as possible. So, if you need secrets stored in your project settings, there are several good options linked above that you should explore.

License

Use of this repository is authorized under the Apache Software License 2.0.

Metadata

Release files for bobbie 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bobbie 0.4.0
File Size Uploaded Provenance Actions
bobbie-0.4.0.tar.gz 119.0 kB Without provenance Details for bobbie-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bobbie 0.4.0
File Interpreter ABI Platform Actions
bobbie-0.4.0-py3-none-any.whl Python 3 none any Details for bobbie-0.4.0-py3-none-any.whl

Total release size: 136.9 kB

Release files / bobbie-0.4.0.tar.gz

Download URL bobbie-0.4.0.tar.gz
Size 119.0 kB
Tags Source
SHA-256 checksum
How to use checksums
36fbbb50aaf72cfb12055de313b7a296e20a5f6e7a7312e6006bb88fe4608f22
BLAKE2b-256 checksum
How to use checksums
6996216ff12c0fb666e54ea2d2080430a94d850af363004e158f75fbf482facf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / bobbie-0.4.0-py3-none-any.whl

Download URL bobbie-0.4.0-py3-none-any.whl
Size 17.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b8baeed33ec4e4681184318f4f90ab7d826b6e910a69936c0371c5106dec73ee
BLAKE2b-256 checksum
How to use checksums
23594f643ab67831003637b669341a43cbb30937df7d177acc8548934a762081
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for bobbie 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page