Fixed pyright errors across modules#130
Merged
olehermanse merged 8 commits intocfengine:masterfrom Apr 1, 2026
Merged
Conversation
ab5edfb to
d66e22f
Compare
olehermanse
reviewed
Apr 1, 2026
olehermanse
requested changes
Apr 1, 2026
Member
olehermanse
left a comment
There was a problem hiding this comment.
Looks good overall, please improve the first commit a bit.
AttributeObject uses dynamic setattr() in __init__, which pyright cannot analyze statically. Adding __getattr__ with an Any return type tells pyright that dynamic attribute access is valid, while preserving correct runtime behavior (AttributeError for truly missing attributes). Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Renamed safe_promiser to promiser to match the base class PromiseModule.evaluate_promise() signature. The parameter already receives the safe promiser via prepare_promiser_and_attributes(). Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Renamed safe_promiser to promiser to match the base class PromiseModule.evaluate_promise() signature. The parameter already receives the safe promiser via prepare_promiser_and_attributes(). Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Added missing promiser parameter to match the base class PromiseModule.create_attribute_object() signature. Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Changed evaluate_command_policy return type from Result to str, since Result.KEPT and Result.REPAIRED are string class attributes, not Result instances. Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
This prints the unified diff of formatting changes on failure, making it easier to manually fix issues when black versions disagree. Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Due to conflicting versions of black. Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Contributor
Author
from cfengine_module_library import AttributeObject
a = AttributeObject({"x": 1, "y": 2})
print("Accessing x:", a.x)
print("Accessing y:", a.y)
print("Accessing z:")
a.z |
Member
|
@larsewi please put it in a comment - the code looks weird as is. |
fb19d18 to
d6b6342
Compare
olehermanse
approved these changes
Apr 1, 2026
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.
Summary
__getattr__with-> Anyreturn type toAttributeObjectso pyright accepts dynamic attribute accessResult.NOTKEPTtypo in gpg module (NOT_KEPT)evaluate_promiseparameter name mismatches in ansible and systemd modules to match base class signaturecreate_attribute_objectsignature in json module to match base classevaluate_command_policyreturn type annotation in iptables module (Result->str)🤖 Generated with Claude Code