Releases: ameily/cincoconfig
Releases · ameily/cincoconfig
v0.9.0
Added
- New support method,
is_value_defined
to check if a config field value is defined by the user,
through either a loaded config file or the API. - New support method,
reset_value
to reset a configuration value back to the default. - New Config method,
Config._set_default_value
, to set a field default value. This was added so
that__setdefault__
methods wouldn't need to access the_data
dictionary directly. - New options to the
DictField
that control key and value validation.
Internal API Changes
- Switched to GitHub Actions.
- Switched to ruff, pyright, and black for linting and formatting.
- Switched to poetry for dependency management.
v0.8.0
Added
- Improved full reference path detection for both field and configuration objects.
- New internal
ConfigTypeField
that allows a schema field to reference aConfigType
class, as
returned by thecincoconfig.make_type
function. - New method,
asdict
, to get a Config values as adict
. - New method,
get_fields
, to get all fields within a Schema or Config.
Deprecated
- Work was done to reduce methods exposed by the
Schema
andConfig
classes by moving the
functions out of the class. This methods are still available in the class but will be removed
in v1.0.0.Schema.instance_method
: usecincoconfig.instance_method
instead.Schema.generate_argparse_parser
: usecincoconfig.generate_argparse_parser
instead.Schema.make_type
: usecincoconfig.make_type
instead.Schema.validator
: usecincoconfig.validator
instead.Schema.get_all_fields
: usecincoconfig.get_all_fields
instead.Schema.full_path
andConfig.full_path
: usecincoconfig.item_ref_path
instead.Config.cmdline_args_override
: usecincoconfig.cmdline_args_override
instead.
BaseSchema
andBaseConfig
were removed and their functionality merged into their concrete
classes,Schema
andConfig
, respectively. cincoconfig will continues to provideBaseConfig
andBaseSchema
aliases but these will be removed in v1.0.0.FormatRegistry
functionality integrated intoConfigFormat
.
Internal API Changes
Field
subclasses were broken out into separate modules.Field.key
was renamed toField._key
to be consistent withSchema
andConfig
.Field.schema
was renamed toField._schema
to be consistent withSchema
andConfig
.cincoconfig.abc
andcincoconfig.config
modules were integrated into a newcincoconfig.core
module.
v0.7.0
Added
- Support for the
~
home directory symbol. All filenames are passed through the
os.path.expanduser
function. IPv4NetworkField
now support setting a minimum and maximum prefix length, in bits.Field.help
attribute to document the field, similar to a docstring. Thehelp
and
autogeneratedshort_help
attribute, can be used in UI to display information and
documentation about the field.BaseSchema.generate_argparse_parser
method to autogenerate anargparse.ArgumentParser
object to parse command line arguments.Field.env
andSchema.env
to control automatically loading configuration values from
environment variables.
Changed
- Improved error reporting with the
ValidationError
exception that contains the offending
field's full name and path.
v0.6.0
[v0.6.0] - 2020-11-05
Added
Field.sensitive
property to mark a value as sensitive.Config.to_tree()
now supports masking sensitive values (sensitive_mask
parameter) and
including virtual fields in the tree (virtual
parameter).
Changed
StringField
now only accepts string values. Prior to this release, all input values were
coerced to a string, viastr(value)
. This was causing inconsistencies and non-intuitive
behavior for fields that inherited fromStringField
.- Refactor
ListProxy
to inherit fromlist
.
Fixed
ListField
now handles empty orNone
values.
v0.5.0
[v0.5.0] - 2020-10-31
Added
StringField
: Provide available choices in the raised exception when value is not valid.Field.friendly_name()
to retrieve the friendly name of the field, either theField.name
or
the full path to the field in the configuration,Field.full_path()
Config.__contains__()
to check if a configuration has a field value set.
Changed
- All exceptions raised during validation are now wrapped in a
ValidationError
exception that
contains the friendly name or full path to the field. SecureField
: Do not encrypt empty string or null values.
Fixed
- Properly evaluate nested
IncludeField
. FilenameField
: Properly validate and handle required filename values.ListField
: Properly handle a list of complex or Schema objects.ListField
: Wrap the defaultListField
value in aListProxy
object.SecureField
: Properly loadbest
encrypted values.SecureField
: Resolvebest
encryption method to a concrete method (aes or xor) during
encryption.
v0.4.0
[0.4.0] - 2020-07-25
Added
Schema.__getitem__()
implementation to get a schema field programmatically.Schema.get_all_fields()
to recursively get all the fields and nested fields from a schema.
Changed
- The Schema fields are now stored in an
OrderedDict
so that the original order that the fields
were added to the Schema is preserved when tterating over the Schema's fields, viaiter()
or
the newget_all_fields()
.
v0.2.1
v0.2.0
-
Improve usability of reusable schemas, such as when a configuration has a list of complex types. The new
Schema.make_type
method creates a new type that can be used like a traditional Python class.webhook_schema = Schema() webhook_schema.url = UrlField(required=True) webhook_schema.verify_ssl = BoolField(default=True) WebHook = webhook_schema.make_type('WebHook') # WebHook is now a new type schema = Schema() schema.issue_webhooks = ListField(webhook_schema) schema.merge_request_webhooks = ListField(webhook_schema) config = schema() wh = WebHook(url='https://google.com') config.issue_webhooks.append(wh)
-
Simplify how custom config-level validations are performed using a decorator.
schema = Schema() schema.x = IntField() schema.y = IntField() schema.db.username = StringField() schema.db.password = StringField() @schema.validator def validate_x_lt_y(cfg): # validates that x < y if cfg.x and cfg.y and cfg.x >= cfg.y: raise ValueError('x must be less-than y') @schema.db.validator def validate_db_creds(cfg): # validates that if the db username is specifed then the password must # also be specified. if cfg.username and not db.password: raise ValueError('db.password is required when username is specified') config = schema() config.load('mycfg.json', format='json') # will call the above validators