v2.0.0
Breaking Changes
python-inject has been removed. All functions that previously used the global inject container now require an explicit AhbContext parameter.
Removed
python-injectdependencyEvaluatableDataProviderclass (replaced by passingEvaluatableDatadirectly viaAhbContext)create_and_inject_hardcoded_evaluators()function (useAhbContext.from_content_evaluation_result()instead)content_evaluation_result_setterparameter onis_valid_expression()(useedifact_format+edifact_format_versionparams instead)- The inject-based binding pattern (
inject.clear_and_configure,binder.bind(TokenLogicProvider, ...), etc.)
Changed to required parameters
| Function | Parameter |
|---|---|
evaluate_ahb_expression_tree(tree, ahb_context) |
ahb_context: AhbContext (was Optional, now required) |
requirement_constraint_evaluation(expr, ahb_context) |
ahb_context: AhbContext (was Optional, now required) |
format_constraint_evaluation(expr, ahb_context) |
ahb_context: AhbContext (was Optional, now required) |
ConditionNodeBuilder(keys, ahb_context) |
ahb_context: AhbContext (was Optional, now required) |
is_valid_expression(expr, edifact_format, edifact_format_version) |
format params now required; also accepts optional ahb_context |
parse_expression_including_unresolved_subexpressions and extract_categorized_keys keep ahb_context as optional — it's only needed when resolve_packages=True.
Migration Guide
Step 1: Replace inject setup with AhbContext (pre-computed results)
This is the simplest path — for consumers that already have a ContentEvaluationResult.
Before (v1.x with inject):
import inject
from ahbicht.content_evaluation.evaluationdatatypes import EvaluatableDataProvider
from ahbicht.content_evaluation.evaluator_factory import create_and_inject_hardcoded_evaluators
create_and_inject_hardcoded_evaluators(cer, evaluatable_data_provider=my_provider, ...)
tree = await parse_expression_including_unresolved_subexpressions(expr, resolve_packages=True)
result = await evaluate_ahb_expression_tree(tree)After (v2.0):
from ahbicht.content_evaluation.ahb_context import AhbContext
from ahbicht.expressions.expression_resolver import parse_expression_including_unresolved_subexpressions
from ahbicht.expressions.ahb_expression_evaluation import evaluate_ahb_expression_tree
from efoli import EdifactFormat, EdifactFormatVersion
ctx = AhbContext.from_content_evaluation_result(cer, EdifactFormat.UTILMD, EdifactFormatVersion.FV2504)
tree = await parse_expression_including_unresolved_subexpressions(expr, resolve_packages=True, ahb_context=ctx)
result = await evaluate_ahb_expression_tree(tree, ahb_context=ctx)Step 2: Replace is_valid_expression setter callback
Before:
await is_valid_expression(tree, lambda cer: my_context_var.set(cer))After:
from efoli import EdifactFormat, EdifactFormatVersion
await is_valid_expression(tree, edifact_format=EdifactFormat.UTILMD, edifact_format_version=EdifactFormatVersion.FV2504)is_valid_expression now builds a fresh AhbContext for each possible CER internally — no setter callback or inject needed.
Step 3: For custom evaluators (e.g. message validators like wanna.bee)
If you used inject.configure(... clear=True) per element to swap in different evaluators, replace it by constructing a new AhbContext for each evaluation scope.
Before:
inject.clear_and_configure(lambda binder: binder
.bind(TokenLogicProvider, SingletonTokenLogicProvider([my_rc, my_fc, my_hints, my_pkg]))
.bind_to_provider(EvaluatableDataProvider, my_provider)
)
result = await evaluate_ahb_expression_tree(tree)After (option A — direct construction):
from ahbicht.content_evaluation.ahb_context import AhbContext
from ahbicht.content_evaluation.evaluationdatatypes import EvaluatableData
ctx = AhbContext(
rc_evaluator=my_rc,
fc_evaluator=my_fc,
hints_provider=my_hints,
package_resolver=my_pkg,
evaluatable_data=EvaluatableData(body=my_data, edifact_format=my_format, edifact_format_version=my_version),
)
result = await evaluate_ahb_expression_tree(tree, ahb_context=ctx)After (option B — bridge from existing TokenLogicProvider):
If you already have a configured TokenLogicProvider, use the bridge factory:
ctx = AhbContext.from_token_logic_provider(my_token_logic_provider, my_evaluatable_data)
result = await evaluate_ahb_expression_tree(tree, ahb_context=ctx)Note: Create a fresh AhbContext per evaluation scope. This replaces the old inject.configure(..., clear=True) per-element pattern.
Step 4: Remove inject from your dependencies
python-inject is no longer pulled in by ahbicht. If your project only used it because of ahbicht, you can remove it.
Pinning for gradual migration
If you cannot migrate immediately, pin to the last v1.x release:
ahbicht>=1.4.0,<2.0.0
What's Changed
- feat: refactor is_valid_expression to support AhbContext by @hf-kklein in #751
- feat!: remove python-inject dependency by @hf-kklein in #752
Full Changelog: v1.4.0...v2.0.0