lazr.config is a Python library for defining configuration schemas, processing configuration data from various sources (like files or command-line arguments), and validating that data against the defined schema. It ensures that applications receive well-formed and valid configurations, reducing runtime errors. The current version is 3.1, and it typically follows an as-needed release cadence driven by Launchpad's requirements.
pip install lazr.configVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define a configuration schema using `ConfigurationSchema` and `Field`, and then create a validated `Config` instance from a Python dictionary. It also shows how type mismatches lead to `ConfigError`.
Upgrade your Python environment to 3.8 or newer. If Python 2 is required, use lazr.config<3.0 and be aware it is no longer maintained.
Ensure that the data provided to the `Config` object, regardless of its source, strictly conforms to the types defined in the `ConfigurationSchema`.
All configuration parameters you intend to use must be explicitly declared as `Field`s within your `ConfigurationSchema`. If you need dynamic access, consider using `Config.get_raw_data()` to access the underlying dictionary.
For file-based configuration, use `ConfigFile(schema, config_file_path)` and then `config_object.config` or similar. For command-line, use `CommandLineArgumentParser(schema)` to parse arguments into a `Config` instance.