Repository navigation
Conversation
Adds `any_fact` and `all_fact` to combine zero-argument facts with explicit OR and AND semantics. Their conditions retrieve facts lazily from the current executing host and short-circuit. Bare `FactBase` and `ShortFactBase` subclasses are rejected during preparation before operation registration, including conditions inherited from deploy or host arguments. Documentation explains the helpers, empty-condition behavior, and lambdas for facts requiring arguments. Fixes pyinfra-dev#2041
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
An operation gated on a bare fact class always runs, even when the fact would be falsey. The condition is silently accepted without collecting the fact.
Fact classes pass callable validation, but invoking them constructs a truthy instance instead of retrieving a fact value.
_iftherefore evaluates the instance rather than the fact.Summary of the fix
Adds
any_factandall_factto combine zero-argument facts with explicit OR and AND semantics. Their conditions retrieve facts lazily from the current executing host and short-circuit. BareFactBaseandShortFactBasesubclasses are rejected during preparation before operation registration, including conditions inherited from deploy or host arguments. Documentation explains the helpers, empty-condition behavior, and lambdas for facts requiring arguments.Verification
The targeted tests (
tests/test_api/test_api_operations.py,tests/test_operations_utils.py) pass, 111 tests, and the fullpytestsuite passes (2252 passed).ruff check,ruff format --check,mypyandscripts/lint_arguments_sync.pyall pass.3.xat this time)scripts/dev-test.sh)scripts/dev-lint.sh)Fixes #2041
AI disclosure:
AI was used for assistance.