Add error behavior per check#825
Open
languitar wants to merge 2 commits into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #825 +/- ##
==========================================
- Coverage 95.93% 95.91% -0.03%
==========================================
Files 21 21
Lines 1502 1517 +15
Branches 129 130 +1
==========================================
+ Hits 1441 1455 +14
Misses 46 46
- Partials 15 16 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
21c7a18 to
4d71260
Compare
The name parameter is removed from Check.__init__, Check.create, and all concrete check implementations. Logging now uses the class name via logger_by_class_instance. This is a breaking change preparing for the ConfiguredCheck wrapper which will hold name and error behavior. BREAKING CHANGE: Check.create no longer accepts a name argument; subclasses must update their create() and __init__ signatures accordingly.
651b2b0 to
5a84322
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds a per-check configuration option to control how temporary check failures (raising TemporaryCheckError) influence suspension decisions, addressing issue #814.
Changes:
- Introduces
ErrorBehaviorand aConfiguredCheckwrapper to attach configured name + error handling policy to each check. - Updates execution logic to optionally treat temporary errors as inactive (
ignore) instead of active (active). - Refactors check factories/constructors and updates tests + documentation to match the new configuration and instantiation model.
Reviewed changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/autosuspend/__init__.py |
Parses error_behavior, wraps checks in ConfiguredCheck, and updates check/wakeup execution to use configured error handling. |
src/autosuspend/checks/__init__.py |
Adds ErrorBehavior + ConfiguredCheck and changes the check factory/init interfaces. |
src/autosuspend/checks/{command,ical,json,kodi,linux,logs,mpd,smb,stub,systemd,util,xorg,xpath}.py |
Adapts built-in checks to the updated create()/__init__() signatures (removal of name parameter). |
tests/test_autosuspend.py |
Updates unit tests to use ConfiguredCheck and adds coverage for ignore-vs-active error behavior during execution. |
tests/test_checks*.py, tests/__init__.py |
Updates tests to the new constructor/factory signatures and removes name-related expectations. |
doc/source/configuration_file.inc |
Documents the new error_behavior option and shows it in the example config. |
setup.cfg |
Enables mypy’s exhaustive-match error code. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+76
to
+77
| def __init__(self) -> None: | ||
| self.logger = logger_by_class_instance(self) |
| raise ConfigurationError( | ||
| "Check %s is not a correct %s instance", check, target_class.__name__ | ||
| ) | ||
| _logger.debug("Created check instance %s with options %s", check, check.options()) |
24bc3b5 to
f066f12
Compare
Adds a well-known option to each activity check for defining how temporary check errors should be treated: ignore or treat the system as active. For the implementation: adds an ErrorBehavior enum (ACTIVE/IGNORE) and ConfiguredCheck dataclass to checks/__init__.py. Wire ConfiguredCheck through set_up_checks, _set_up_single_check, execute_checks, execute_wakeups, Processor, and configure_processor. The error_behavior config option controls whether temporary check errors prevent suspension (ACTIVE) or are silently ignored (IGNORE, default). Fixes: #814
f066f12 to
5dc8108
Compare
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.
Fixes #814